diff options
author | Knut Auvor Grythe <knut@auvor.no> | 2015-03-31 16:04:44 +0200 |
---|---|---|
committer | Knut Auvor Grythe <knut@auvor.no> | 2015-03-31 16:04:44 +0200 |
commit | 69747efcf8aca1a3c1241eb126bf0d0e27b8af05 (patch) | |
tree | e7a86213e402f9f6a4e42584b17104e6b5e418b0 | |
parent | aef116e3b3644f2b86b8c34150bb19fe5afe669f (diff) |
clean up juniper-ssh code
-rwxr-xr-x | clients/smanagrun.pl | 10 | ||||
-rwxr-xr-x | include/nms.pm | 6 | ||||
-rwxr-xr-x | web/nms.gathering.org/ssendfile.pl | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/clients/smanagrun.pl b/clients/smanagrun.pl index 9f8efab..a68edf8 100755 --- a/clients/smanagrun.pl +++ b/clients/smanagrun.pl @@ -91,9 +91,8 @@ while (1) { mylog("Connecting to $switch->{sysname} on $switch->{addr}"); eval { - #my $conn = switch_connect($switch->{addr}); - my $telnet = switch_connect_ssh($switch->{addr}); - my $conn = $telnet->{telnet}; + my $ssh = switch_connect_ssh($switch->{addr}); + my $conn = $ssh->{telnet}; if (!defined($conn)) { mylog("Could not connect to ".$switch->{sysname}."(".$switch->{addr}.")"); $sdelay->execute("Could not connect to switch, delaying...", $switch->{sysname}); @@ -125,8 +124,9 @@ while (1) { $sresult->execute($result, $row->{id}); } $conn->close(); - waitpid($telnet->{pid}, 0); + waitpid($ssh->{pid}, 0); $sunlock->execute($switch->{sysname}); - } + }; + warn $@ if $@; } diff --git a/include/nms.pm b/include/nms.pm index 479e013..589f7f0 100755 --- a/include/nms.pm +++ b/include/nms.pm @@ -10,7 +10,7 @@ use FileHandle; package nms; use base 'Exporter'; -our @EXPORT = qw(switch_disconnect switch_connect_ssh switch_connect switch_exec switch_timeout db_connect); +our @EXPORT = qw(switch_disconnect switch_connect_ssh switch_connect_dlink switch_exec switch_timeout db_connect); BEGIN { require "config.pm"; @@ -75,7 +75,7 @@ sub switch_connect_ssh($) { return { telnet => $telnet, ssh => $ssh, pid => $pid, pty => $pty }; } -sub switch_connect($) { +sub switch_connect_dlink($) { my ($ip) = @_; my $dumplog = FileHandle->new; @@ -110,7 +110,7 @@ sub switch_connect($) { $conn->cmd($nms::config::tacacs_pass); } } - return ($conn); + return { telnet => $conn }; } # Send a command to switch and return the data recvied from the switch diff --git a/web/nms.gathering.org/ssendfile.pl b/web/nms.gathering.org/ssendfile.pl index ec2ebb8..835a966 100755 --- a/web/nms.gathering.org/ssendfile.pl +++ b/web/nms.gathering.org/ssendfile.pl @@ -19,7 +19,8 @@ if ($#ARGV != 1) { "./ssendfile.pl addr configfile\n"); } -my $conn = nms::switch_connect($ARGV[0]); +my $ssh = nms::switch_connect_ssh($ARGV[0]); +my $conn = $ssh->{telnet}; if (!defined($conn)) { die("Could not connect to switch.\n"); } @@ -33,7 +34,8 @@ while (<CONFIG>) { # print "New ip: $1\n"; # $conn->cmd( String => $cmd, # Timeout => 3); -# $conn = nms::switch_connect($1); +# $ssh = nms::switch_connect_ssh($1); +# $conn = $ssh->{telnet}; # if (!defined($conn)) { # die "Could not connect to new ip: $1\n"; # } |