Skip to content

Commit 78461d8

Browse files
committed
Wrap paramiko's proxy command failure into a pssh exception class. Added error logging on proxy command error
1 parent ae337dd commit 78461d8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pssh.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class AuthenticationException(Exception):
6060
pass
6161

6262

63+
class ProxyCommandException(Exception):
64+
"""Raised on ProxyCommand error - ProxyCommand configured exited with error"""
65+
pass
66+
67+
6368
class SSHClient(object):
6469
"""Wrapper class over paramiko.SSHClient with sane defaults
6570
Honours ~/.ssh/config and /etc/ssh/ssh_config entries for host username \
@@ -86,7 +91,9 @@ def __init__(self, host,
8691
:type pkey: :mod:`paramiko.PKey`
8792
:raises: :mod:`pssh.AuthenticationException` on authentication error
8893
:raises: :mod:`pssh.UnknownHostException` on DNS resolution error
89-
:raises: :mod:`pssh.ConnectionErrorException` on error connecting"""
94+
:raises: :mod:`pssh.ConnectionErrorException` on error connecting
95+
:raises: :mod:`pssh.ProxyCommandError` on error with ProxyCommand \
96+
configured"""
9097
ssh_config = paramiko.SSHConfig()
9198
_ssh_config_file = os.path.sep.join([os.path.expanduser('~'),
9299
'.ssh',
@@ -145,6 +152,10 @@ def _connect(self, retries=1):
145152
self.port,))
146153
except paramiko.AuthenticationException, e:
147154
raise AuthenticationException(e)
155+
except paramiko.ProxyCommandFailure, e:
156+
logger.error("Error executing ProxyCommand - %s" % (
157+
e.message,))
158+
raise ProxyCommandException(e.message)
148159

149160
def exec_command(self, command, sudo=False, **kwargs):
150161
"""Wrapper to :mod:`paramiko.SSHClient.exec_command`

0 commit comments

Comments
 (0)