Urgent fix: Paramiko does not change some exceptions to SSHException

Paramiko does not change some exceptions to SSHException ->
  use broad except

Change-Id: Ic8c18725d0d84f1ce1aa2c956ed860fc6280ff02
(cherry picked from commit 4ca798e)
This commit is contained in:
Alexey Stepanov
2016-07-20 12:07:06 +03:00
parent 1037067721
commit 0ab5cededb

View File

@@ -231,9 +231,10 @@ class _MemorizedSSH(type):
username=username, password=password, keys=private_keys)
if hash((cls, host, port, auth)) == hash(cls.__cache[key]):
ssh = cls.__cache[key]
# noinspection PyBroadException
try:
ssh.execute('cd ~', timeout=5)
except (paramiko.SSHException, AttributeError, TimeoutError):
except BaseException: # Note: Do not change to lower level!
logger.debug('Reconnect {}'.format(ssh))
ssh.reconnect()
return ssh