[#51] Collect nsIfMngIp when getting IP interfaces in L3::Netscreen

This commit is contained in:
Eric A. Miller
2014-01-04 18:33:20 -05:00
parent b4c3f92ba3
commit d82d8781c4
2 changed files with 23 additions and 3 deletions

View File

@@ -6,6 +6,9 @@ version 3.11
* Modify cdp_cap() to handle devices which return space delimited strings * Modify cdp_cap() to handle devices which return space delimited strings
for cdpCacheCapabilities rather than hex strings for cdpCacheCapabilities rather than hex strings
* [#51] Netdisco shows broken topology for devices with no alias entry
for primary IP - Collect nsIfMngIp when getting IP interfaces in
L3::Netscreen
version 3.10 (2013-12-16) version 3.10 (2013-12-16)

View File

@@ -345,30 +345,47 @@ sub _mac_map {
return \%mac_map; return \%mac_map;
} }
# Interfaces can have two addresses, we want to capture both the network
# address and the management address
sub ip_index { sub ip_index {
my $netscreen = shift; my $netscreen = shift;
my $ns_ip = $netscreen->ns_ip_table() || {}; my $ns_ip = $netscreen->ns_ip_table() || {};
my $if_mng_ip = $netscreen->nsIfMngIp() || {};
my %ip_index = (); my %ip_index = ();
foreach my $iid ( keys %$ns_ip ) { foreach my $iid ( keys %$ns_ip ) {
$ip_index{ $ns_ip->{$iid} } = $iid if $ns_ip->{$iid} ne "0.0.0.0"; $ip_index{ $ns_ip->{$iid} } = $iid if $ns_ip->{$iid} ne "0.0.0.0";
} }
foreach my $iid ( keys %$if_mng_ip ) {
$ip_index{ $if_mng_ip->{$iid} } = $iid
if $if_mng_ip->{$iid} ne "0.0.0.0";
}
return \%ip_index; return \%ip_index;
} }
sub ip_table { sub ip_table {
my $netscreen = shift; my $netscreen = shift;
my $ip_index = $netscreen->ip_index() || {}; my $ip_index = $netscreen->ip_index() || {};
my $if_mng_ip = $netscreen->nsIfMngIp() || {};
my %ip_table = (); my %ip_table = ();
foreach my $iid ( keys %$ip_index ) { foreach my $iid ( keys %$ip_index ) {
$ip_table{$iid} = $iid; my $mgmt_ip = $if_mng_ip->{$iid};
if ( defined $mgmt_ip && $mgmt_ip ne '0.0.0.0' ) {
$ip_table{$iid} = $mgmt_ip;
}
else {
$ip_table{$iid} = $iid;
}
} }
return \%ip_table; return \%ip_table;
} }
# There is only one netmask for the interface both network and management
# addresses should have the same netmask
sub ip_netmask { sub ip_netmask {
my $netscreen = shift; my $netscreen = shift;