Skip to content

Commit

Permalink
Tries to address #7463
Browse files Browse the repository at this point in the history
- run the remote `bridge` command in a login shell, to make sure PATH is
  properly defined
- add `set -o pipefail` to ensure that errors are properly propagated
  back through the remote SSH command
  • Loading branch information
kcgthb committed Aug 8, 2024
1 parent 6b8c669 commit 959672e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion perl-xCAT/xCAT/MacMap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ sub refresh_switch {
my $mymac;
my $myport;

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);
my @res=xCAT::Utils->runcmd("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no $switch \"bash -lc 'set -o pipefail; 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}) {
Expand Down Expand Up @@ -774,6 +774,7 @@ sub refresh_switch {
}
}


my $session = $self->getsnmpsession('community' => $community, 'switch' => $switch);
unless ($session) {
xCAT::MsgUtils->message("S", "Failed to communicate with $switch");
Expand Down

0 comments on commit 959672e

Please sign in to comment.