blib/lib/App/Netdisco/SSHCollector/Platform/Aruba.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 31 CC 1 SCAR 6.9
CC
1
Cov
0%
arpnip
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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;