diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 54edb1824..f95d01091 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -356,6 +356,8 @@ sub dump_mac_info { } } @{ $ret{$switch}->{$snmpportname}->{MACaddress} } = @{ $self->{macinfo}->{$switch}->{$snmpportname} }; + @{ $ret{$switch}->{$snmpportname}->{Vlanid} } = @{ $self->{vlaninfo}->{$switch}->{$snmpportname} }; + @{ $ret{$switch}->{$snmpportname}->{Mtu} } = @{ $self->{mtuinfo}->{$switch}->{$snmpportname} }; } } } @@ -720,6 +722,12 @@ sub refresh_switch { return; } + # get mtu + my $iftomtumap = walkoid($session, '.1.3.6.1.2.1.2.2.1.4', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); + unless (defined($iftomtumap)) { + xCAT::MsgUtils->message("I", "MTU information is not availabe for this switch $switch"); + } + #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 @@ -783,24 +791,38 @@ sub refresh_switch { xCAT::MsgUtils->message("S", "Error communicating with " . $session->{DestHost} . ": Unable to get MAC entries via either BRIDGE or Q-BRIDE MIB"); return; } + if (defined($self->{collect_mac_info})) { my %index_to_mac = (); + my %index_to_vlan = (); foreach (keys %$mactoindexmap) { my $index = $mactoindexmap->{$_}; my @tmp = split /\./, $_; + 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; } foreach my $boid (keys %$bridgetoifmap) { my $port_index = $boid; my $port_name = $namemap->{ $bridgetoifmap->{$port_index} }; + my $mtu = $iftomtumap->{ $bridgetoifmap->{$port_index} }; if (defined($index_to_mac{$port_index})) { push @{ $self->{macinfo}->{$switch}->{$port_name} }, @{ $index_to_mac{$port_index} }; } else { $self->{macinfo}->{$switch}->{$port_name}->[0] = ''; } + + if (defined($index_to_vlan{$port_index})) { + push @{ $self->{vlaninfo}->{$switch}->{$port_name} }, @{ $index_to_vlan{$port_index} }; + } + else { + $self->{vlaninfo}->{$switch}->{$port_name}->[0] = ''; + } + push @{ $self->{mtuinfo}->{$switch}->{$port_name} } , $mtu; + } return; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 61dbce696..f4330a883 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -230,12 +230,12 @@ sub process_request { } } } - my $format = "%-" . $switch_name_length . "s %-" . $port_name_length . "s %-18s %s"; + my $format = "%-" . $switch_name_length . "s %-" . $port_name_length . "s %-18s %-20s %-7s %s"; my %failed_switches = (); - my $header = sprintf($format, "Switch", "Port", "MAC address", "Node"); + my $header = sprintf($format, "Switch", "Port", "MAC address", "Node", "Vlan", "MTU"); if (!defined($req->{opt}->{check}) and $port_name_length) { $cb->({ data => $header }); - $cb->({ data => "------------------------------------------------------------------" }) + $cb->({ data => "--------------------------------------------------------------------------------------" }) } foreach my $switch (keys %$macinfo) { if (defined($macinfo->{$switch}->{ErrorStr})) { @@ -251,17 +251,34 @@ sub process_request { $cb->({ node => [ { name => $switch, data => ["PASS"] } ] }); next; } + foreach my $port (sort keys %{ $macinfo->{$switch} }) { my $node = ''; if (defined($macinfo->{$switch}->{$port}->{Node})) { $node = $macinfo->{$switch}->{$port}->{Node}; } + + my $mtu = ''; + my @mtuarray = (); + if (defined($macinfo->{$switch}->{$port}->{Mtu})) { + @mtuarray = @{ $macinfo->{$switch}->{$port}->{Mtu} }; + } + my $vlanid = ''; + my @vlans = (); + if (defined($macinfo->{$switch}->{$port}->{Vlanid})) { + @vlans = @{ $macinfo->{$switch}->{$port}->{Vlanid} }; + } + my @macarrary = (); if (defined($macinfo->{$switch}->{$port}->{MACaddress})) { @macarray = @{ $macinfo->{$switch}->{$port}->{MACaddress} }; + my $ind = 0; foreach (@macarray) { - my $data = sprintf($format, $switch, $port, ($_ ne '') ? $_ : ' N/A', $node); + $vlanid = $vlans[$ind]; + $mtu = $mtuarray[$ind]; + my $data = sprintf($format, $switch, $port, ($_ ne '') ? $_ : ' N/A', $node,$vlanid,$mtu); $cb->({ data => $data }); + $ind++; #$cb->({node=>[{name=>$switch,data=>$data}]}); } @@ -269,7 +286,7 @@ sub process_request { } } if (!defined($req->{opt}->{check}) and $port_name_length) { - $cb->({ data => "------------------------------------------------------------------" }) + $cb->({ data => "--------------------------------------------------------------------------------------" }) } foreach (keys %failed_switches) { $cb->({ node => [ { name => $_, error => [ $failed_switches{$_} ], errorcode => 1 } ] });