From ad7793909cf1fe9e27b62142072937edf5bc5549 Mon Sep 17 00:00:00 2001 From: Matt Ezell Date: Thu, 17 Aug 2017 00:05:45 -0400 Subject: [PATCH] Skip built-in MAC addresses on switches Newer Cumulus versions show a MAC address on each port. Those MACs aren't discoverable devices, so skip them to clean up the 'xcatprobe switch_macmap' output. --- perl-xCAT/xCAT/MacMap.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 426cf1619..e1a7df81f 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -734,6 +734,9 @@ sub refresh_switch { xCAT::MsgUtils->message("I", "MTU information is not availabe for this switch $switch"); } + # get port state + my $mactostate = walkoid($session, '.1.3.6.1.2.1.17.7.1.2.2.1.3', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); + #Above is valid without community string indexing, on cisco, we need it on the next one and onward my $iftovlanmap = walkoid($session, '.1.3.6.1.4.1.9.9.68.1.2.2.1.2', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); #use cisco vlan membership mib to ascertain vlan my $trunktovlanmap = walkoid($session, '.1.3.6.1.4.1.9.9.46.1.6.1.1.5', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); #for trunk ports, we are interested in the native vlan, so we need cisco vtp mib too @@ -807,8 +810,11 @@ sub refresh_switch { my $vlan = @tmp[0]; my @mac = @tmp[ -6 .. -1 ]; my $macstring = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", @mac); - push @{ $index_to_mac{$index} }, $macstring; - push @{ $index_to_vlan{$index} }, $vlan; + # Skip "permanent" ports + if (!defined($mactostate->{$_}) || $mactostate->{$_} != 4) { + push @{ $index_to_mac{$index} }, $macstring; + push @{ $index_to_vlan{$index} }, $vlan; + } } foreach my $boid (keys %$bridgetoifmap) { my $port_index = $boid;