Control-CLI-AvayaData
view release on metacpan or search on metacpan
lib/Control/CLI/AvayaData.pm view on Meta::CPAN
package Control::CLI::AvayaData;
use strict;
use warnings;
use Exporter qw( import );
use Carp;
use Control::CLI qw( :all );
my $Package = __PACKAGE__;
our $VERSION = '2.05';
our @ISA = qw(Control::CLI);
our %EXPORT_TAGS = (
use => [qw(useTelnet useSsh useSerial useIPv6)],
prompt => [qw(promptClear promptHide promptCredential)],
args => [qw(parseMethodArgs suppressMethodArgs)],
coderef => [qw(validCodeRef callCodeRef)],
_rest => [qw(passphraseRequired parse_errmode stripLastLine poll)],
);
push @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} foreach keys %EXPORT_TAGS;
Exporter::export_ok_tags('all');
########################################### Global Class Variables ###########################################
my %LoginPatterns = ( # Patterns to check for during device login (Telnet/Serial) and initial connection to CLI
bell => "\x07",
banner => 'Enter Ctrl-Y to begin',
menu => 'Use arrow keys to highlight option, press <Return> or <Enter> to select option',
submenu => 'Press Ctrl-R to return to previous menu. Press Ctrl-C to return to Main Menu',
username => 'Enter Username: ',
password => "Enter Password: \e[?", # Should match only on the initial password prompt and not subsequent ones where * are printed
lastlogin => 'Failed retries since last login:',
localfail => 'Incorrect',
radiusfail => 'Access Denied from RADIUS',
radiustimeout1 => 'no response from RADIUS servers',
radiustimeout2 => 'No reply from RADIUS server',
srbanner => "\((?:Secure Router|VSP4K)",
xlrbanner => "\x0d************************************\n",
ersbanner => "\x0d* Ethernet Routing Switch",
passportbanner => "\x0d* Passport 8",
pp1600banner => "\x0d* Passport 16", # The 6 ensures this does not trigger on old Accelar 1x00
vspbanner => "All Rights Reserved.\n\x0dVirtual Services Platform",
consoleLogMsg1 => "connected via console port", #On serial port: GlobalRouter SW INFO user rwa connected via console port
consoleLogMsg2 => "Blocked unauthorized ACLI access",
more1 => '----More (q=Quit, space/return=Continue)----',
more2 => '--More--',
wlan9100banner => 'Avaya Wi-Fi Access Point',
);
my %Prm = ( # Hash containing list of named parameters returned by attributes
bstk => 'BaystackERS',
pers => 'PassportERS',
xlr => 'Accelar',
sr => 'SecureRouter',
trpz => 'WLAN2300',
xirrus => 'WLAN9100',
generic => 'generic',
);
my %Attribute = (
Global => [
'family_type',
'is_nncli',
'is_acli',
'model',
'sw_version',
'fw_version',
'slots',
'ports',
'sysname',
'base_mac',
'baudrate',
'max_baud',
],
$Prm{pers} => [
'is_voss',
'is_apls',
'apls_box_type',
'brand_name',
'is_master_cpu',
'is_dual_cpu',
'cpu_slot',
'is_ha',
'stp_mode',
'oob_ip',
'oob_virt_ip',
'oob_standby_ip',
'is_oob_connected',
],
$Prm{bstk} => [
'unit_number',
'base_unit',
'switch_mode',
'stack_size',
'stp_mode',
'mgmt_vlan',
'mgmt_ip',
'oob_ip',
'is_oob_connected',
],
$Prm{xlr} => [
'is_master_cpu',
'is_dual_cpu',
lib/Control/CLI/AvayaData.pm view on Meta::CPAN
);
my %MorePromptDelay = ( # Only when a possible more prompt can be matched as subset of other more prompt patterns; for these an extra silent read is required
$Prm{bstk} => undef,
"$Prm{pers}_cli" => undef,
"$Prm{pers}_nncli" => '--More--',
$Prm{xlr} => undef,
$Prm{sr} => undef,
$Prm{trpz} => undef,
$Prm{xirrus} => undef,
$Prm{generic} => '--More--',
);
our %ErrorPatterns = ( # Patterns which indicated the last command sent generated a syntax error on the host device
$Prm{bstk} => '^('
. '\s+\^\n.+'
. '|% Invalid input detected at \'\^\' marker\.'
. '|% Cannot modify settings'
. '|% Bad (?:port|unit) number\.'
. '|% MLT \d+ does not exist or it is not enabled'
. '|% No such VLAN'
. '|% Bad VLAN list format\.'
. '|% View name does not exist' # snmp-server user admin read-view root write-view root notify-view root
. '|% Partial configuration of \'.+?\' already exists\.' # same as above
. '|% View already exists, you must first delete it\.' # snmp-server view root 1
. '|% User \w+ does not exist' # no snmp-server user admindes
. '|% User \'.+?\' already exists' # snmp-server user admin md5 passwdvbn read-view root write-view root notify-view root
. '|% Password length must be in range:' # username add rwa role-name RW password // rwa // rwa (with password security)
. '|% Bad format, use forms:' # vlan members add 71 1/6-1/7 (1/6-7 is correct)
. ')',
$Prm{pers} => '^('
. '\x07?\s+\^\n.+'
. '|% Invalid input detected at \'\^\' marker\.'
. '|.+? not found in path .+'
. '|(?:parameter|object) .+? is out of range'
. '|\x07?Error ?: .+'
. '|Unable to .+'
. '|% Not allowed on secondary cpu\.'
. '|% Incomplete command\.'
. '|% Vrf "[^"]+" does not exist'
. '| ERROR: copy failed \(code:0x[\da-fA-F]+\)'
. '|Save config to file [^ ]+ failed\.'
. '|% Vlan \d+ does not exist'
. '|Command not allowed MSTP RSTP mode\.' # On MSTP switch : vlan create 101 type port 1
. '|% Permission denied\.' # TACACS commands not allowed
. '|% Only (?:gigabit|fast) ethernet ports allowed' # config interface gig on fastEth port or vice-versa
. '|There are \d+ releases already on system. Please remove 1 to proceed'
. '|can\'t \w+ ".+?" 0x\d+' # delete /flash/.ssh -y : can't remove "/flash/.ssh" 0x300042
. '|".+?" is ambiguous in path /' # AccDist3:5#% do
. '|Password change aborted\.' # Creating snmpv3 usm user with enh-secure-mode and password does not meet complexity requirements
. '|Invalid password. Authentication failed' # username teamnoc level ro // invalid-old-pwd // ...
. '|Passwords do not match. Password change aborted' # username teamnoc level ro // valid-old-pwd // newpwd // diffpwd
. '|Error: Prefix List ".+?" not found' # no ip prefix-list "<non-existent>"
. '|Invalid ipv4 address\.' # filter acl ace action 11 6 permit redirect-next-hop 2000:100::201 (on a non-ipv6 acl)
. ')',
$Prm{xlr} => '^('
. '.+? not found'
. '|(?:parameter|object) .+? is out of range'
. ')',
$Prm{sr} => '^('
. '\s+\^\n.+'
. '|Error : Command .+? does not exist'
. '|Config is locked by some other user'
. ')',
$Prm{trpz} => '^('
. '\s+\^\n.+'
. '|Unrecognized command:.+'
. '|Unrecognized command in this mode:.+'
. ')',
$Prm{xirrus} => '^('
. '\s+\^\n.+'
. ')',
);
our $CmdConfirmPrompt = '[\(\[] *(?:[yY](?:es)? *(?:[\\\/]|or) *[nN]o?|[nN]o? *(?:[\\\/]|or) *[yY](?:es)?) *[\)\]] *[?:] *$'; # Y/N prompt
our $CmdInitiatedPrompt = '[?:=][ \t]*$'; # Prompt for additional user info
our $WakeConsole = "\n"; # Sequence to send when connecting to console to wake device
my $LoginReadAttempts = 10; # Number of read attempts for readwait() method used in login()
my $CmdPromptReadAttempts = 5; # Number of read attempts for readwait() method used in poll_cmd()
my $ReadwaitTimer = 100; # Timer to use when calling readwait()
my $CmdTimeoutRatio = 0.1; # In cmd() if read times out, a 2nd read is attempted with timeout * this ratio
my $Space = " ";
my $CTRL_C = "\cC";
my $CTRL_U = "\cU";
my $CTRL_X = "\cX";
my $CTRL_Y = "\cY";
my $CTRL_Z = "\cZ";
my %Default = ( # Hash of default object seetings which can be modified on a per object basis
morePaging => 0, # For --more-- prompt, number of pages accepted before sending q to quit
# 0 = accept all pages; 1 = send q after 1st page, i.e. only 1 page; etc
progressDots => 0, # After how many bytes received, an activity dot is printed; 0 = disabled
return_result => 0, # Whether cmd methods return true/false result or output of command
cmd_confirm_prompt => $CmdConfirmPrompt,
cmd_initiated_prompt => $CmdInitiatedPrompt,
cmd_feed_timeout => 10, # Command requests for data, we have none, after X times we give up
wake_console => $WakeConsole,
);
our @ConstructorArgs = ( @Control::CLI::ConstructorArgs, 'return_result', 'more_prompt', 'more_paging', 'debug_file',
'cmd_confirm_prompt', 'cmd_initiated_prompt', 'cmd_feed_timeout', 'console', 'wake_console',
);
# Debug levels can be set using the debug() method or via debug argument to new() constructor
# Debug levels defined:
# 0 : No debugging
# bit 1 : Control::CLI - Debugging activated for polling methods + readwait() + Win32/Device::SerialPort constructor $quiet flag reset
# bit 2 : Control::CLI - Debugging is activated on underlying Net::SSH2 and Win32::SerialPort / Device::SerialPort
# bit 4 : Control::CLI::AvayaData - Basic debugging
# bit 8 : Control::CLI::AvayaData - Extended debugging of login() & cmd() methods
############################################# Constructors/Destructors #######################################
sub new {
my $pkgsub = "${Package}::new";
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my (%args, %cliArgs);
my $debugLevel = $Default{debug};
if (@_ == 1) { # Method invoked with just the connection type argument
$cliArgs{use} = shift;
( run in 1.906 second using v1.01-cache-2.11-cpan-39bf76dae61 )