aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-04-13 15:51:23 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-04-13 16:55:12 +0200
commitcd7dd1a5994bc255a839c4c30c750d496285f8d7 (patch)
treefe7d2db5a22fc6f9957a8e097fc45c3aab3f492b /rumba/ssh_support.py
parenta766f2d202eaf586b8da5f678e9a8a21b31448d7 (diff)
downloadrumba-cd7dd1a5994bc255a839c4c30c750d496285f8d7.tar.gz
rumba-cd7dd1a5994bc255a839c4c30c750d496285f8d7.zip
rumba: ssh_support: Fix passing of array
The array was returned back instead of the raw output of stdout after executing a command, resulting in weird behaviour.
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index c6615c3..30ada62 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -33,7 +33,7 @@ def _print_stream(stream):
o_array = o.split('\\n')
for oi in o_array:
print(oi)
- return o_array
+ return o
def execute_commands(testbed, ssh_config, commands, time_out=3):
'''
@@ -53,16 +53,19 @@ def execute_commands(testbed, ssh_config, commands, time_out=3):
ssh_client.connect(ssh_config.hostname, ssh_config.port,
testbed.username, testbed.password,
look_for_keys=True, timeout=time_out)
+ o = ""
for command in commands:
print("%s@%s:%s >> %s" % (testbed.username,
- ssh_config.hostname, ssh_config.port, command))
+ ssh_config.hostname,
+ ssh_config.port,
+ command))
envars = '. /etc/profile;'
command = envars + ' ' + command
stdin, stdout, stderr = ssh_client.exec_command(command)
- o_array = _print_stream(stdout)
+ o = _print_stream(stdout)
_print_stream(stderr)
ssh_client.close()
- return o_array
+ return o
except Exception as e:
print(str(e))
@@ -82,9 +85,9 @@ def execute_command(testbed, ssh_config, command, time_out=3):
@return: stdout resulting from the command
'''
- o_array = execute_commands(testbed, ssh_config, [command], time_out)
- if o_array != None:
- return o_array[0]
+ o = execute_commands(testbed, ssh_config, [command], time_out)
+ if o != None:
+ return o
def copy_file_to_testbed(testbed, ssh_config, text, file_name):
'''