use Net::Telnet();
use strict;
use warnings;
package L_Switch;
sub new {
my $class = shift;
my ($location, $ip, $time, $client) = @_;
my $self = {};
my $sucClass;
if ((defined $client) and ($client eq "Veda")){
$subClass = "L_Switch::L_Veda";
}
eval "use $subClass;";
eval "\$self = $subClass -> new();";
}
sub login {
my $self = shift;
my $utility = L_Utility -> new();
$self -> {'telnetConn'} -> open($self -> {ip});
$self -> {'telnetConn'} -> login($self -> {'username'}, $self -> {'password'});
if ($self -> {'time_out'} == 1) # checking timed-out switches
{
$self -> {'full_info'} = $self -> {'full_info'} . "," . $self -> {'location'};
$self -> {'full_info'} = $self -> {'full_info'} . "," . $self -> {'fault'} . "," . $self -> {'time'} . ",,,,,";
return $self -> {'full_info'};
}
return "0";
}
1;
####
package L_Switch::L_Veda;
require L_Switch;
@ISA = qw(L_Switch);
use strict;
use warnings;
use NET::SSH2;
sub new { } # something in here
sub login {
my $self = shift;
$self -> {'ssh'} -> connect($self -> {'ip'});
$self -> {'ssh'} -> auth_password($self -> {'username'}, $self -> {'password'});
return 0;
}
1;
####
use L_Switch;
use strict;
use warnings;
my $utility = L_Utility -> new();
my $switch = L_Switch -> new("", '127.0.0.1', "", "Veda");
$switch -> login();
print $switch -> getFullInfo();