From 8cb0c0917bd3ea306fda055707ea0ed49c57f20a Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 25 Feb 2015 22:07:16 +0000 Subject: [PATCH] Support enable password in ASA sshcollector (M. Sheinberg) --- Netdisco/Changes | 6 +++++ .../App/Netdisco/SSHCollector/Platform/ACE.pm | 2 +- .../App/Netdisco/SSHCollector/Platform/ASA.pm | 27 +++++++++++++++++-- .../Netdisco/SSHCollector/Platform/BigIP.pm | 2 +- .../App/Netdisco/SSHCollector/Platform/IOS.pm | 2 +- .../Netdisco/SSHCollector/Platform/IOSXR.pm | 2 +- .../SSHCollector/Platform/PaloAlto.pm | 2 +- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index add247f5..23c9af23 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,9 @@ +2.031010 - 2015-02-25 + + [ENHANCEMENTS] + + * Support enable password in ASA sshcollector (M. Sheinberg) + 2.031009 - 2015-02-25 [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ACE.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ACE.pm index f518a365..3b047b03 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ACE.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ACE.pm @@ -41,7 +41,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip{ - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()"; diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ASA.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ASA.pm index a0ecc1d9..3dd94a2c 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ASA.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/ASA.pm @@ -14,6 +14,16 @@ C status after login: aaa authorization exec LOCAL auto-enable +To use an C password seaparate from the login password, add an +C under C in your configuration file: + + sshcollector: + - ip: '192.0.2.1' + user: oliver + password: letmein + enable_password: myenablepass + platform: IOS + =cut use strict; @@ -37,7 +47,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip { - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()"; @@ -45,8 +55,21 @@ sub arpnip { my $expect = Expect->init($pty); my ($pos, $error, $match, $before, $after); - my $prompt = qr/#/; + my $prompt; + if ($args->{enable_password}) { + $prompt = qr/>/; + ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); + + $expect->send("enable\n"); + + $prompt = qr/Password:/; + ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); + + $expect->send( $args->{enable_password} ."\n" ); + } + + $prompt = qr/#/; ($pos, $error, $match, $before, $after) = $expect->expect(10, -re, $prompt); $expect->send("terminal pager 2147483647\n"); diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/BigIP.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/BigIP.pm index 2592342a..9dd47e5f 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/BigIP.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/BigIP.pm @@ -38,7 +38,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip { - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()"; diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOS.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOS.pm index 36e14cb7..774f9294 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOS.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOS.pm @@ -32,7 +32,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip { - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()"; my @data = $ssh->capture("show ip arp"); diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOSXR.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOSXR.pm index e101c765..48a2ca11 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOSXR.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/IOSXR.pm @@ -32,7 +32,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip { - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()"; my @data = $ssh->capture("show arp vrf all"); diff --git a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/PaloAlto.pm b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/PaloAlto.pm index 458287d8..e8e78d3a 100644 --- a/Netdisco/lib/App/Netdisco/SSHCollector/Platform/PaloAlto.pm +++ b/Netdisco/lib/App/Netdisco/SSHCollector/Platform/PaloAlto.pm @@ -33,7 +33,7 @@ Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }. =cut sub arpnip{ - my ($self, $hostlabel, $ssh, @args) = @_; + my ($self, $hostlabel, $ssh, $args) = @_; debug "$hostlabel $$ arpnip()";