From fe249bfb70106e0db310db05b8dee9728369199c Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 11 Apr 2018 02:03:56 -0400 Subject: [PATCH] Print out error msg for xcatprobe switch_macmap command if switch passwordless is not enabled (#5064) * Print out error msg for xcatprobe switch_mac command if switch passwordless is not enabled. * Modified msg only if in the collect_mac_info case --- perl-xCAT/xCAT/MacMap.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 2a1931397..1c8668411 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -356,7 +356,7 @@ sub dump_mac_info { $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; # To show the error message that the username/password related error is for SNMP only - if ($ret{$switch}->{ErrorStr} =~ /user\s*name|password/i) { + if ($ret{$switch}->{ErrorStr} =~ /user\s*name|password$/i) { $ret{$switch}->{ErrorStr} .= " through SNMP"; } } else { @@ -729,6 +729,11 @@ sub refresh_switch { my @res=xCAT::Utils->runcmd("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no $switch 'bridge fdb show|grep -i -v permanent|tr A-Z a-z 2>/dev/null' 2>/dev/null",-1); if ($::RUNCMD_RC) { xCAT::MsgUtils->message("S", "Failed to get mac table with ssh to $switch, fall back to snmp! To obtain mac table with ssh, please make sure the passwordless root ssh to $switch is available"); + if ($self->{collect_mac_info}) { + my $errmsg = "Failed to get MAC table from $switch. Make sure passwordless SSH to the switch is enabled."; + $self->{macinfo}->{$switch}->{ErrorStr} = $errmsg; + return; + } }else{ foreach (@res){ if($_ =~ m/^([0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}) dev swp([0-9]+) vlan ([0-9]+) .*/){