X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=web%2Fsmanagement.pl;h=ed783b2fa915b245f821f92c9d19675416df061c;hb=6f01d8d8981b4a668709516f75a482588a66c4ba;hp=e6474586eb467bc45b3a248e352e0b260074f887;hpb=2679e59589f8338def31c4b7b5c35a365df00d05;p=nms diff --git a/web/smanagement.pl b/web/smanagement.pl index e647458..ed783b2 100755 --- a/web/smanagement.pl +++ b/web/smanagement.pl @@ -1,23 +1,11 @@ #!/usr/bin/perl -use lib '../include'; -use nms; -# -# - -my $username = ''; -my $password = 'removed'; - -# Seconds to wait for connection -my $timeout = 15; - - use warnings; use strict; -use Switch; use CGI; -use Net::Telnet; use DBI; use Data::Dumper; +use lib '../include'; +use nms; # Grab from .htaccess-authentication my $user = $ENV{'REMOTE_USER'}; @@ -34,43 +22,6 @@ my $sgetip = $dbh->prepare("SELECT ip FROM switches WHERE sysname = ?") or die "Could not prepare sgetip"; my $sgid = $dbh->prepare("SELECT nextval('squeue_group_sequence') as gid"); -# Send a command to switch and return the data recvied from the switch -sub switch_exec($$) { - my ($cmd, $conn) = @_; - - # Send the command and get data from switch - my @data = $conn->cmd($cmd); - my @lines = (); - foreach my $line (@data) { - # Remove escape-7 sequence - $line =~ s/\x1b\x37//g; - push (@lines, $line); - } - - return @lines; -} - -sub switch_connect($) { - my ($ip) = @_; - - my $conn = new Net::Telnet( Timeout => $timeout, - Errmode => 'return', - Prompt => '/(es3024|e\d+\-\dsw)>/i'); - my $ret = $conn->open( Host => $ip); - if (!$ret || $ret != 1) { - return (0); - } - # XXX: Just send the password as text, I did not figure out how to - # handle authentication with only password through $conn->login(). - #$conn->login( Prompt => '/password[: ]*$/i', - # Name => $password, - # Password => $password); - $conn->cmd($password); - # Get rid of banner - $conn->get; - return ($conn); -} - sub parse_range($) { my $switches = $_; my @range;