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

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 CC 4 SCAR 24.0
CC
4
Cov
0%
arpnip
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 11.0
1 package App::Netdisco::SSHCollector::Platform::Clavister;
2  
3 =head1 NAME
4  
5 App::Netdisco::SSHCollector::Platform::Clavister
6  
7 =head1 DESCRIPTION
8  
9 Collect ARP entries from Clavister firewalls.
10 These devices does not expose mac table through snmp.
11  
12 =cut
13  
14 use strict;
15 use warnings;
16  
17 use Dancer ':script';
18 use Moo;
19  
20 =head1 PUBLIC METHODS
21  
22 =over 4
23  
24 =item B<arpnip($host, $ssh)>
25  
26 Retrieve ARP entries from device. C<$host> is the hostname or IP address
27 of the device. C<$ssh> is a Net::OpenSSH connection to the device.
28 Returns an array of hashrefs in the format { mac => MACADDR, ip => IPADDR }.
29  
30 =back
31  
32 =cut
33  
34 sub arpnip {
35 my ($self, $hostlabel, $ssh, @args) = @_;
36 debug "$hostlabel $$ arpnip()";
37  
38 my @data = $ssh->capture("neighborcache");
39 chomp @data;
40 my @arpentries;
41  
42 foreach (@data){
43 next if /^Contents of Active/;
44 next if /^Idx/;
45 next if /^---/;
46 my @fields = split /\s+/, $_;
47 my $mac = $fields[2];
48 my $ip = $fields[3];
49 push(@arpentries, {mac => $mac, ip => $ip});
50 }
51 return @arpentries;
52 }
53  
54 1;