fix undefined variable error on NXOS (#854)
Only process entries with defined (IPv4/v6 address). Older code was bombing out here to undefiend entries for ip when process NXOS CLI arpnip.
This commit is contained in:
@@ -92,13 +92,27 @@ register_worker({ phase => 'main', driver => 'cli' }, sub {
|
|||||||
# should be both v4 and v6
|
# should be both v4 and v6
|
||||||
my @arps = @{ get_arps_cli($device, [$cli->arpnip]) };
|
my @arps = @{ get_arps_cli($device, [$cli->arpnip]) };
|
||||||
|
|
||||||
# cache v4 arp table
|
my $a_entry;
|
||||||
push @{ vars->{'v4arps'} },
|
my $a_ip;
|
||||||
grep { NetAddr::IP::Lite->new($_->{ip})->bits == 32 } @arps;
|
my $a_mac;
|
||||||
|
|
||||||
# cache v6 neighbor cache
|
# should be both v4 and v6
|
||||||
push @{ vars->{'v6arps'} },
|
my @arps = @{ get_arps_cli($device, [$cli->arpnip]) };
|
||||||
grep { NetAddr::IP::Lite->new($_->{ip})->bits == 128 } @arps;
|
|
||||||
|
foreach $a_entry (@arps) {
|
||||||
|
$a_ip = NetAddr::IP::Lite->new($a_entry->{ip});
|
||||||
|
|
||||||
|
if (defined($a_ip)) {
|
||||||
|
# IPv4
|
||||||
|
if ($a_ip->bits == 32 ) {
|
||||||
|
push @{ vars->{"v4arps"} }, $a_entry;
|
||||||
|
}
|
||||||
|
# IPv6
|
||||||
|
if ($a_ip->bits == 128 ) {
|
||||||
|
push @{ vars->{"v6arps"} }, $a_entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$device->update({layers => \[q{overlay(layers placing '1' from 6 for 1)}]});
|
$device->update({layers => \[q{overlay(layers placing '1' from 6 for 1)}]});
|
||||||
return Status->done("Gathered arp caches from $device");
|
return Status->done("Gathered arp caches from $device");
|
||||||
|
|||||||
Reference in New Issue
Block a user