aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-06-01 16:43:03 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-06-01 16:43:03 +0200
commit30dbd8b5493480d2c302380735083c2d9b8f8260 (patch)
tree3f683a207ba7c4767c0e0870db8cddacc0205354 /rumba/ssh_support.py
parent24c375545c6ef7d03e8a18dea2cb06763059b1b9 (diff)
downloadrumba-30dbd8b5493480d2c302380735083c2d9b8f8260.tar.gz
rumba-30dbd8b5493480d2c302380735083c2d9b8f8260.zip
model: added proxy field. ssh: added execute_proxy_commands
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index cb36910..93a48f8 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -43,6 +43,48 @@ def _print_stream(stream):
return o
+def execute_proxy_commands(testbed, ssh_config, commands, time_out=3):
+ """
+ Remote execution of a list of shell command on hostname, using the
+ http and https proxy specified by the testbed. By
+ default this function will exit (timeout) after 3 seconds.
+
+ @param testbed: testbed info
+ @param ssh_config: ssh config of the node
+ @param commands: *nix shell command
+ @param time_out: time_out value in seconds, error will be generated if
+ no result received in given number of seconds, the value None can
+ be used when no timeout is needed
+ """
+ new_commands = []
+ for command in commands:
+ proxy = testbed.http_proxy
+ proxy_command = 'export http_proxy=' + proxy + '; ' \
+ + 'export https_proxy=' + proxy + ';'
+ new_commands.append(proxy_command + ' ' + command)
+ return execute_commands(testbed, ssh_config, new_commands, time_out)
+
+
+def execute_proxy_command(testbed, ssh_config, command, time_out=3):
+ """
+ Remote execution of a list of shell command on hostname, using
+ a proxy http and https.
+ By default this function will exit (timeout) after 3 seconds.
+
+ @param testbed: testbed info
+ @param ssh_config: ssh config of the node
+ @param command: *nix shell command
+ @param time_out: time_out value in seconds, error will be generated if
+ no result received in given number of seconds, the value None can
+ be used when no timeout is needed
+
+ @return: stdout resulting from the command
+ """
+ o = execute_proxy_commands(testbed, ssh_config, [command], time_out)
+ if o is not None:
+ return o
+
+
def execute_commands(testbed, ssh_config, commands, time_out=3):
"""
Remote execution of a list of shell command on hostname. By