| version 1.18, 2006/09/12 03:13:08 |
version 1.22, 2007/01/03 19:40:03 |
|
|
| package Net::Telnet::Trango; |
package Net::Telnet::Trango; |
| # $RedRiver: Trango.pm,v 1.17 2006/09/12 01:17:46 andrew Exp $ |
# $RedRiver: Trango.pm,v 1.21 2006/10/05 17:10:39 andrew Exp $ |
| use strict; |
use strict; |
| use warnings; |
use warnings; |
| use base 'Net::Telnet'; |
use base 'Net::Telnet'; |
|
|
| |
|
| Perl access to the telnet interface on Trango Foxes, SUs and APs. |
Perl access to the telnet interface on Trango Foxes, SUs and APs. |
| |
|
| Another handy feature is that it will parse the output from certain commands that is in the format "[key1] value1 [key2] value2" and put those in a hashref that is returned. This makes using the output from things like sysinfo very easy to do. |
Another handy feature is that it will parse the output from certain |
| |
commands that is in the format "[key1] value1 [key2] value2" and put |
| |
those in a hashref that is returned. This makes using the output from |
| |
things like sysinfo very easy to do. |
| |
|
| =head2 EXPORT |
=head2 EXPORT |
| |
|
|
|
| |
|
| =item login_banner |
=item login_banner |
| |
|
| returns the banner that is displayed when first connected at login. Only set after a successful open() |
returns the banner that is displayed when first connected at login. |
| |
Only set after a successful open() |
| |
|
| This is usually only set internally |
This is usually only set internally |
| |
|
|
|
| |
|
| =head2 COMMANDS |
=head2 COMMANDS |
| |
|
| Most of these are just shortcuts to C<cmd(String =E<gt> METHOD)>, as such they accept the same options as C<cmd()>. Specifically they take a named paramater "args", for example: |
Most of these are just shortcuts to C<cmd(String =E<gt> METHOD)>, |
| |
as such they accept the same options as C<cmd()>. |
| |
Specifically they take a named paramater "args", for example: |
| C<tftpd(args =E<gt> 'on')> would enable tftpd |
C<tftpd(args =E<gt> 'on')> would enable tftpd |
| |
|
| =over |
=over |
|
|
| |
|
| You need to pass in args => <suid> and it will return the info for that suid. |
You need to pass in args => <suid> and it will return the info for that suid. |
| |
|
| |
=item su_testrflink |
| |
|
| |
you need to pass in args => <suid> and it will return the rflink test results for that SU. |
| |
|
| =item save_ss |
=item save_ss |
| |
|
| saves the config. Returns 1 on success, undef on failure. |
saves the config. Returns 1 on success, undef on failure. |
|
|
| 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 }, |
su_info => { String => 'su info', decode => 'all', expect => $success }, |
| |
su_testrflink=> { String => 'su testrflink', decode => 'each', expect => $success }, |
| save_ss => { String => 'save ss', expect => $success }, |
save_ss => { String => 'save ss', expect => $success }, |
| |
opmode => { decode => 'all', expect => $success }, |
| # eth r, w and reset??? |
# eth r, w and reset??? |
| #su password??? |
#su password??? |
| #_bootloader |
#_bootloader |
|
|
| |
|
| =item open |
=item open |
| |
|
| Calls Net::Telnet::open() then makes sure you get a password prompt so you are ready to login() and parses the login banner so you can get host_type() and firmware_version() |
Calls Net::Telnet::open() then makes sure you get a password prompt so |
| |
you are ready to login() and parses the login banner so you can get |
| |
host_type() and firmware_version() |
| |
|
| =cut |
=cut |
| |
|
|
|
| |
|
| =item login |
=item login |
| |
|
| Calls open() if not already connected, then sends the password and sets logged_in() if successful |
Calls open() if not already connected, then sends the password and sets |
| |
logged_in() if successful |
| |
|
| =cut |
=cut |
| |
|
|
|
| |
|
| =item parse_login_banner |
=item parse_login_banner |
| |
|
| Takes a login banner (what you get when you first connect to the Trango) or reads what is already in login_banner() then parses it and sets host_type() and firmware_version() as well as login_banner() |
Takes a login banner (what you get when you first connect to the Trango) |
| |
or reads what is already in login_banner() then parses it and sets |
| |
host_type() and firmware_version() as well as login_banner() |
| |
|
| =cut |
=cut |
| |
|
|
|
| |
|
| =item cmd |
=item cmd |
| |
|
| This does most of the work. At the heart, it calls Net::Telnet::cmd() but it also does some special stuff for Trango. |
This does most of the work. At the heart, it calls Net::Telnet::cmd() |
| |
but it also does some special stuff for Trango. |
| |
|
| Normally returns the last lines from from the command |
Normally returns the last lines from from the command |
| |
|
| Also accepts these options: |
Also accepts these options: |
| |
|
| I<decode> |
I<decode> |
| - if this is true, then it will send the output lines to _decode_lines() and then returns the decoded output |
- if this is true, then it will send the output lines to _decode_lines() |
| |
and then returns the decoded output |
| |
|
| I<cmd_disconnects> |
I<cmd_disconnects> |
| - if this is true, it then sets logged_in() to false, then it will close() the connection and then sets is_connected() to false |
- if this is true, it then sets logged_in() to false, then it will |
| |
close() the connection and then sets is_connected() to false |
| |
|
| I<expect> |
I<expect> |
| - if this is set (usually to 'Success.') it will check for that in the last line of output and if it does not, will return undef because the command probably failed |
- if this is set (usually to 'Success.') it will check for that in the |
| |
last line of output and if it does not, will return undef because the |
| |
command probably failed |
| |
|
| I<args> |
I<args> |
| - a string containing the command line options that are passed to the command |
- a string containing the command line options that are passed to the |
| |
command |
| |
|
| =cut |
=cut |
| |
|
|
|
| |
|
| =head1 SEE ALSO |
=head1 SEE ALSO |
| |
|
| Trango Documentation - http://www.trangobroadband.com/support/product_docs.htm |
Trango Documentation - |
| |
http://www.trangobroadband.com/support/product_docs.htm |
| |
|
| L<Net::Telnet> |
L<Net::Telnet> |
| |
|
| =head1 TODO |
=head1 TODO |
| |
|
| There are still a lot of commands that are not accessed directly. If you call them (as cmd("command + args") or whatever) and it works, please send me examples that work and I will try to get it incorporated into the next version of the script. |
There are still a lot of commands that are not accessed directly. If |
| |
you call them (as cmd("command + args") or whatever) and it works, |
| |
please send me examples that work and I will try to get it incorporated |
| |
into the next version of the script. |
| |
|
| I also want to be able to parse the different types of output from commands like su, sudb all and anything else that would be better available as a perl datastructure. |
I also want to be able to parse the different types of output from |
| |
commands like su, sudb all and anything else that would be better |
| |
available as a perl datastructure. |
| |
|
| =head1 AUTHOR |
=head1 AUTHOR |
| |
|