aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index 60a3767..3103811 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:
@@ -180,17 +181,33 @@ def execute_commands(testbed, ssh_config, commands, time_out=3):
raise SSHException('Failed to execute command')
o = _print_stream(stdout)
if chan.recv_exit_status() != 0:
+ # Get ready for printing stdout and stderr
+ if o != "":
+ list_print = ['**** STDOUT:']
+ list_print += o.split('\\n')
+ else:
+ list_print = []
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 ""))
+ if e != "":
+ list_print.append('**** STDERR:')
+ list_print += e.split('\\n')
+ raise SSHException('A remote command returned an error. '
+ 'Output:\n\n\t' +
+ '\n\t'.join(list_print) + '\n')
return o
finally:
- ssh_config.client.close()
- if ssh_config.proxy_client is not None:
- ssh_config.proxy_client.close()
- ssh_config.client = None
- ssh_config.proxy_client = None
+ ##
+ # The following lines are a fix to make this work under
+ # true multiprocessing. Right now we are using
+ # dummy multiprocessing (i.e. threading), so not needed.
+ # They have been kept here in case we want to get back to it.
+ ##
+ # ssh_config.client.close()
+ # if ssh_config.proxy_client is not None:
+ # ssh_config.proxy_client.close()
+ # ssh_config.client = None
+ # ssh_config.proxy_client = None
+ pass
def execute_command(testbed, ssh_config, command, time_out=3):
"""
@@ -329,6 +346,7 @@ def setup_vlans(testbed, node, vlans):
execute_commands(testbed, node.ssh_config, cmds)
+
def aptitude_install(testbed, node, packages):
"""
Installs packages through aptitude