aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-11-09 17:14:48 +0100
committerMarco Capitani <m.capitani@nextworks.it>2017-11-09 17:14:48 +0100
commit667a7a587163c0ff5507c3a0188dea050681b84a (patch)
tree394897ce3e63c9ed9e6b3e5f8c37817b40a07784 /rumba/ssh_support.py
parentc7eb260d8b8d8d5e57199a19be348219e9703870 (diff)
downloadrumba-667a7a587163c0ff5507c3a0188dea050681b84a.tar.gz
rumba-667a7a587163c0ff5507c3a0188dea050681b84a.zip
SSH: added stderr to output in case of commmand error
Diffstat (limited to 'rumba/ssh_support.py')
-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