aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-11-07 11:40:54 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-11-15 18:59:11 +0100
commit2da15caf24a8b2da70d755e065a5dc3d770c6454 (patch)
tree292456db4acc4ab8f4afffad50113cc7e219b6cd /rumba/ssh_support.py
parent2e91ca33f90f7c74887013e08c95bb00cdd4fc00 (diff)
downloadrumba-2da15caf24a8b2da70d755e065a5dc3d770c6454.tar.gz
rumba-2da15caf24a8b2da70d755e065a5dc3d770c6454.zip
prototypes: Add parallel installation for IRATI
This adds parallel installation for IRATI, it also adds support for multithread/multiprocess logging. Furthermore prototype-agnostic utilities for multiprocessing have been added. Caching of clients has been re-enabled for the ssh connections.
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