ffdc: Add verification of remote command exit code.
Add verification of remote command exit code to inform user for
better corrective action.
- Set 1: Added for SSH/SCP group.
Tests:
- Set 1: Regression tested.
Signed-off-by: Peter D Phan <peterp@us.ibm.com>
Change-Id: I3b27483f1f3509ce631aa629aa6b137668703d7a
diff --git a/ffdc/ssh_utility.py b/ffdc/ssh_utility.py
index a8c1253..f363e82 100644
--- a/ffdc/ssh_utility.py
+++ b/ffdc/ssh_utility.py
@@ -73,7 +73,8 @@
if self.scpclient:
self.scpclient.close()
- def execute_command(self, command, default_timeout=60):
+ def execute_command(self, command,
+ default_timeout=60):
"""
Execute command on the remote host.
@@ -92,8 +93,8 @@
if stdout.channel.exit_status_ready():
break
time.sleep(1)
-
- return stderr.readlines(), stdout.readlines()
+ cmd_exit_code = stdout.channel.recv_exit_status()
+ return cmd_exit_code, stderr.readlines(), stdout.readlines()
except (paramiko.AuthenticationException, paramiko.SSHException,
paramiko.ChannelException, SocketTimeout) as e:
@@ -101,7 +102,7 @@
logging.error("\n>>>>>\tERROR: Fail remote command %s %s" % (e.__class__, e))
logging.error(">>>>>\tCommand '%s' Elapsed Time %s" %
(command, time.strftime("%H:%M:%S", time.gmtime(time.time() - cmd_start))))
- return empty, empty
+ return 0, empty, empty
def scp_connection(self):