aboutsummaryrefslogtreecommitdiff
path: root/rumba
diff options
context:
space:
mode:
Diffstat (limited to 'rumba')
-rw-r--r--rumba/ssh_support.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index 93b6ac2..53965f8 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -58,6 +58,7 @@ def _print_stream(stream):
return o.rstrip()
def ssh_connect(hostname, port, username, password, time_out, proxy_server):
+ logger.debug('Trying to open a connection towards node %s.' % hostname)
retry = 0
max_retries = 10
while retry < max_retries:
@@ -172,13 +173,19 @@ def execute_commands(testbed, ssh_config, commands, time_out=3):
command = envars + ' ' + command
chan = ssh_config.client.get_transport().open_session()
stdout = chan.makefile()
+ stderr = chan.makefile_stderr()
try:
chan.exec_command(command)
except paramiko.ssh_exception.SSHException as e:
raise SSHException('Failed to execute command')
o = _print_stream(stdout)
- if (chan.recv_exit_status() != 0):
- raise SSHException('A remote command returned an error.\n' + o)
+ if chan.recv_exit_status() != 0:
+ e = _print_stream(stderr)
+ o_e = o + (('\n' + e) if e != "" else "")
+ raise SSHException('A remote command returned an error.' +
+ (('\n' + o_e) if o_e != "" else ""))
+ ssh_config.client = None
+ ssh_config.proxy_client = None
return o