ffdc: Add checking for scp get_transport error.
When there is an error on scp get_transport,
- Inform user of the error.
- Continue FFDC generation on remote host.
- Inform user to manually offload data.
Test:
- Run OK scenarios.
- Run SCPException and SocketException scenarios.
Signed-off-by: Peter D Phan <peterp@us.ibm.com>
Change-Id: I606bc9530fb1f4b1b1bbe75c5797337f0bd76f2a
diff --git a/ffdc/ssh_utility.py b/ffdc/ssh_utility.py
index 3a028e6..f1524a7 100644
--- a/ffdc/ssh_utility.py
+++ b/ffdc/ssh_utility.py
@@ -6,7 +6,7 @@
from paramiko.ssh_exception import SSHException
from paramiko.ssh_exception import BadHostKeyException
from paramiko.buffered_pipe import PipeTimeout as PipeTimeout
-import scp
+from scp import SCPClient, SCPException
import sys
import socket
from socket import timeout as SocketTimeout
@@ -94,7 +94,14 @@
r"""
Create a scp connection for file transfer.
"""
- self.scpclient = scp.SCPClient(self.sshclient.get_transport())
+ try:
+ self.scpclient = SCPClient(self.sshclient.get_transport())
+ print("\n\t[Check] %s SCP transport established.\t [OK]" % self.hostname)
+ except (SCPException, SocketTimeout, PipeTimeout) as e:
+ self.scpclient = None
+ print("\n>>>>>\tERROR: SCP get_transport has failed. %s %s" % (e.__class__, e))
+ print(">>>>>\tScript continues generating FFDC on %s." % self.hostname)
+ print(">>>>>\tCollected data will need to be manually offloaded.")
def scp_file_from_remote(self, remote_file, local_file):
@@ -111,7 +118,7 @@
try:
self.scpclient.get(remote_file, local_file)
- except (scp.SCPException, SocketTimeout, PipeTimeout) as e:
+ except (SCPException, SocketTimeout, PipeTimeout) as e:
# Log command with error. Return to caller for next file, if any.
print("\n>>>>>\tERROR: Fail scp %s from remotehost %s %s\n\n" % (remote_file, e.__class__, e))
return False