"""
Exception thrown when the connection is lost
"""
- def __init__(self, command):
+ def __init__(self, command, node=None):
self.command = command
+ self.node = node
def __str__(self):
- return "SSH connection was lost: {command!r}".format(
+ node_str = 'to %s ' % self.node if self.node else ''
+ return "SSH connection {node_str}was lost: {command!r}".format(
+ node_str=node_str,
command=self.command,
)
transport = self.client.get_transport()
if transport is None or not transport.is_active():
# look like we lost the connection
- raise ConnectionLostError(command=self.command)
+ raise ConnectionLostError(command=self.command,
+ node=self.hostname)
# connection seems healthy still, assuming it was a
# signal; sadly SSH does not tell us which signal
try:
(host, port) = client.get_transport().getpeername()
except socket.error:
- raise ConnectionLostError(command=quote(args))
+ raise ConnectionLostError(command=quote(args), node=name)
if name is None:
name = host
)
assert e.command == 'foo'
- assert str(e) == "SSH connection was lost: 'foo'"
+ assert str(e) == "SSH connection to HOST was lost: 'foo'"
@fudge.with_fakes
def test_run_status_lost_socket(self):