From 74dca9c43eb29a13610ee967e4565a192503f3a3 Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 7 Nov 2016 02:43:09 -0500 Subject: [PATCH 1/2] fix issue 1650, help to resolve errors --- perl-xCAT/xCAT/MacMap.pm | 4 +++- xCAT-probe/subcmds/switch-macmap | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 077c4d21b..aab0e63ab 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -343,7 +343,9 @@ sub dump_mac_info { } elsif (defined($self->{macinfo}->{$switch}->{ErrorStr})) { $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; - + if ($ret{$switch}->{ErrorStr} =~ /Unknown user name/) { + $ret{$switch}->{ErrorStr} = "Unknown snmp user name"; + } # To show the error message that the username/password related error is for SNMP only if ($ret{$switch}->{ErrorStr} =~ /username|password/i) { $ret{$switch}->{ErrorStr} .= " through SNMP"; diff --git a/xCAT-probe/subcmds/switch-macmap b/xCAT-probe/subcmds/switch-macmap index fbbb0cc6e..3a52ca5df 100755 --- a/xCAT-probe/subcmds/switch-macmap +++ b/xCAT-probe/subcmds/switch-macmap @@ -94,7 +94,7 @@ if (-f $error_file) { my $fd; open($fd, "<", "$normal_file"); my @fails = (); - +my @error_nodes = (); # There is 2 kinds of error message: # 1. Error: The nodetype is not 'switch' for nodes: switch1 # Error: No switch configuration info find for switch-10-5-23-1 @@ -104,6 +104,8 @@ foreach (<$fd>) { if (/Error:/) { if (/^(\S*):\s*Error:\s*(.*)/) { push @fails, "$1 - $2"; + } elsif (/^Error:\s*The nodetype is not 'switch' for nodes: (.+)/) { + push @error_nodes, "$1"; } elsif (/^Error:\s*(.*)/) { push @fails, $1; } else { @@ -124,6 +126,10 @@ if (-f $normal_file) { if (-f $error_file) { unlink($error_file); } +if (@error_nodes) { + my $error_node = join(",", @error_nodes); + probe_utils->send_msg("$output", "d", "[$error_node] : Error, switch-macmap can only be run against xCAT objects that have 'nodetype=switch'"); +} foreach (@fails) { probe_utils->send_msg("$output", "f", "$_"); } From 409e32bd70f8472db2e0b31aca52d6ed93e9c75a Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 8 Nov 2016 02:32:01 -0500 Subject: [PATCH 2/2] modified depending on comments --- perl-xCAT/xCAT/MacMap.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index aab0e63ab..e857cf9f5 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -343,11 +343,9 @@ sub dump_mac_info { } elsif (defined($self->{macinfo}->{$switch}->{ErrorStr})) { $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; - if ($ret{$switch}->{ErrorStr} =~ /Unknown user name/) { - $ret{$switch}->{ErrorStr} = "Unknown snmp user name"; - } + # To show the error message that the username/password related error is for SNMP only - if ($ret{$switch}->{ErrorStr} =~ /username|password/i) { + if ($ret{$switch}->{ErrorStr} =~ /user\s*name|password/i) { $ret{$switch}->{ErrorStr} .= " through SNMP"; } } else {