« blib/lib/App/Netdisco/GenericDB/Result/Virtual/GenericReport.pm
↑ Summary
blib/lib/App/Netdisco/Util/Noop.pm »
| 1 | package App::Netdisco::SSHCollector::Platform::Aruba; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | App::Netdisco::SSHCollector::Platform::Aruba | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | =cut | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use warnings; | ||
| 13 | |||
| 14 | use Dancer ':script'; | ||
| 15 | use Expect; | ||
| 16 | use Moo; | ||
| 17 | |||
| 18 | =head1 PUBLIC METHODS | ||
| 19 | |||
| 20 | =over 4 | ||
| 21 | |||
| 22 | =item B<arpnip($host, $ssh)> | ||
| 23 | |||
| 24 | Retrieve ARP entries from device. C<$host> is the hostname or IP address | ||
| 25 | of the device. C<$ssh> is a Net::OpenSSH connection to the device. | ||
| 26 | |||
| 27 | Returns a list of hashrefs in the format C<{ mac =E<gt> MACADDR, ip =E<gt> IPADDR }>. | ||
| 28 | |||
| 29 | =back | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub arpnip { | ||
| 34 | my ($self, $hostlabel, $ssh, $args) = @_; | ||
| 35 | |||
| 36 | debug "$hostlabel $$ arpnip()"; | ||
| 37 | my @data = $ssh->capture("show arp"); | ||
| 38 | |||
| 39 | chomp @data; | ||
| 40 | my @arpentries; | ||
| 41 | |||
| 42 | # 172.16.20.15 00:24:b2:69:86:7d vlan interface state | ||
| 43 | foreach my $line (@data) { | ||
| 44 | my @fields = split m/\s+/, $line; | ||
| 45 | |||
| 46 | push @arpentries, { mac => $fields[1], ip => $fields[0] }; | ||
| 47 | } | ||
| 48 | return @arpentries; | ||
| 49 | } | ||
| 50 | |||
| 51 | 1; |