version 1.16, 2006/09/07 04:00:07 |
version 1.18, 2006/09/12 03:13:08 |
|
|
package Net::Telnet::Trango; |
package Net::Telnet::Trango; |
# $RedRiver: Trango.pm,v 1.14 2006/09/07 02:49:34 andrew Exp $ |
# $RedRiver: Trango.pm,v 1.17 2006/09/12 01:17:46 andrew Exp $ |
use strict; |
use strict; |
use warnings; |
use warnings; |
use base 'Net::Telnet'; |
use base 'Net::Telnet'; |
|
|
|
|
reboots the trango and closes the connection |
reboots the trango and closes the connection |
|
|
|
=item remarks |
|
|
|
Takes an optional argument, which sets the remarks. |
|
If there is no argument, returns the current remarks. |
|
|
=item sulog |
=item sulog |
|
|
returns an array ref of hashes containing each log line. |
returns an array ref of hashes containing each log line. |
|
|
|
|
returns the output from the eth list command |
returns the output from the eth list command |
|
|
|
=item su_info |
|
|
|
You need to pass in args => <suid> and it will return the info for that suid. |
|
|
|
=item save_ss |
|
|
|
saves the config. Returns 1 on success, undef on failure. |
|
|
=cut |
=cut |
|
|
|
|
|
|
sulog => { decode => 'sulog', expect => $success }, |
sulog => { decode => 'sulog', expect => $success }, |
'exit' => { no_prompt => 1, cmd_disconnects => 1 }, |
'exit' => { no_prompt => 1, cmd_disconnects => 1 }, |
reboot => { no_prompt => 1, cmd_disconnects => 1 }, |
reboot => { no_prompt => 1, cmd_disconnects => 1 }, |
|
remarks => { decode => 'all', expect => $success }, |
save_sudb => { String => 'save sudb', expect => $success }, |
save_sudb => { String => 'save sudb', expect => $success }, |
syslog => { expect => $success }, |
syslog => { expect => $success }, |
'pipe' => { }, # XXX needs a special decode |
'pipe' => { }, # XXX needs a special decode |
maclist => { decode => 'maclist' }, |
maclist => { decode => 'maclist' }, |
maclist_reset => { String => 'maclist reset', expect => 'done' }, |
maclist_reset => { String => 'maclist reset', expect => 'done' }, |
eth_link => { String => 'eth link', expect => $success }, |
eth_link => { String => 'eth link', expect => $success }, |
|
su_info => { String => 'su info', decode => 'all', expect => $success }, |
|
save_ss => { String => 'save ss', expect => $success }, |
# eth r, w and reset??? |
# eth r, w and reset??? |
#su password??? |
#su password??? |
#_bootloader |
#_bootloader |
|
|
} |
} |
|
|
if (exists $COMMANDS{$method}) { |
if (exists $COMMANDS{$method}) { |
$method = shift if (@_ == 1); |
|
$COMMANDS{$method}{'String'} ||= $method; |
$COMMANDS{$method}{'String'} ||= $method; |
|
$COMMANDS{$method}{'args'} .= ' ' . shift if (@_ == 1); |
return $self->cmd(%{ $COMMANDS{$method} }, @_); |
return $self->cmd(%{ $COMMANDS{$method} }, @_); |
} |
} |
|
|
|
|
my %conf; |
my %conf; |
|
|
my $key = ''; |
my $key = ''; |
my $val = ''; |
my $val = undef; |
my $in_key = 0; |
my $in_key = 0; |
my $in_val = 0; |
my $in_val = 1; |
|
|
foreach my $line (@lines) { |
foreach my $line (@lines) { |
next if $line =~ /$success$/; |
next if $line =~ /$success$/; |
|
|
$in_val = 0; |
$in_val = 0; |
} else { |
} else { |
$in_key = 0; |
$in_key = 0; |
$in_val = 0; |
$in_val = 1; |
} |
} |
|
|
if ($key) { |
if ($key) { |
$key =~ s/^\s+//; |
$key =~ s/^\s+//; |
$key =~ s/\s+$//; |
$key =~ s/\s+$//; |
|
|
$val =~ s/^\s+//; |
if (defined $val) { |
$val =~ s/\s+$//; |
$val =~ s/^\s+//; |
|
$val =~ s/\s+$//; |
|
} |
|
|
if ($key eq 'Checksum' && $last_key) { |
if ($key eq 'Checksum' && $last_key) { |
# Special case for these bastids. |
# Special case for these bastids. |
|
|
if (%conf) { |
if (%conf) { |
return \%conf; |
return \%conf; |
} else { |
} else { |
return undef; |
return $val; |
} |
} |
} |
} |
|
|