2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

Tries to address #7463

- 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
This commit is contained in:
Kilian Cavalotti 2024-08-08 15:52:49 -07:00
parent 6b8c669171
commit 959672ef14

View File

@ -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}) {
@ -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");