From bf71393b1c57741d061eee8b1f27f41daebf236f Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 13 Apr 2017 14:21:54 +0200 Subject: rumba: ssh_support: Fix return of stdout Stdout was not being returned properly after a recent commit. This fixes it. --- rumba/testbeds/emulab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'rumba/testbeds') diff --git a/rumba/testbeds/emulab.py b/rumba/testbeds/emulab.py index aee438e..5f85ddb 100644 --- a/rumba/testbeds/emulab.py +++ b/rumba/testbeds/emulab.py @@ -125,7 +125,7 @@ class Testbed(mod.Testbed): ns = self.generate_ns_script(experiment) dest_file_name = '/users/'+ self.username + \ '/temp_ns_file.%s.ns' % os.getpid() - ssh.copy_file_to_testbed(self, self.ops_server(), ns, dest_file_name) + ssh.copy_file_to_testbed(self, self.ops_ssh_config, ns, dest_file_name) cmd = '/usr/testbed/bin/sslxmlrpc_client.py startexp ' + \ 'batch=false wait=true proj="' + proj_name + \ -- cgit v1.2.3 From cd7dd1a5994bc255a839c4c30c750d496285f8d7 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 13 Apr 2017 15:51:23 +0200 Subject: 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. --- rumba/ssh_support.py | 17 ++++++++++------- rumba/testbeds/emulab.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'rumba/testbeds') 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): ''' diff --git a/rumba/testbeds/emulab.py b/rumba/testbeds/emulab.py index 5f85ddb..c031327 100644 --- a/rumba/testbeds/emulab.py +++ b/rumba/testbeds/emulab.py @@ -203,7 +203,7 @@ class Testbed(mod.Testbed): ''' for node in experiment.nodes: - node.ssh_config.hostname = self.full_name(experiment.nodes[0].name) + node.ssh_config.hostname = self.full_name(node.name) cmd = 'cat /var/emulab/boot/topomap' topomap = ssh.execute_command(self, experiment.nodes[0].ssh_config, cmd) -- cgit v1.2.3