aboutsummaryrefslogtreecommitdiff
path: root/rumba
diff options
context:
space:
mode:
authorVincenzo Maffione <v.maffione@gmail.com>2017-06-01 15:42:54 +0000
committerVincenzo Maffione <v.maffione@gmail.com>2017-06-01 15:42:54 +0000
commit7d816ccc891934d34465fc30cc8de1b4d55381f6 (patch)
tree0b8fd76a6034c417f723b2d0129858e34a18b6f8 /rumba
parentf3d700174eed69d612650df3c63e8b56cebf2c52 (diff)
parentc92408dc0a74e2ca1ef47cc721ad41dff614aaa4 (diff)
downloadrumba-7d816ccc891934d34465fc30cc8de1b4d55381f6.tar.gz
rumba-7d816ccc891934d34465fc30cc8de1b4d55381f6.zip
Merge branch 'issue9-proxy' into 'master'
Remove hardcoded proxy See merge request !50
Diffstat (limited to 'rumba')
-rw-r--r--rumba/model.py8
-rw-r--r--rumba/prototypes/irati.py2
-rw-r--r--rumba/prototypes/rlite.py10
-rw-r--r--rumba/ssh_support.py45
-rw-r--r--rumba/testbeds/jfed.py7
5 files changed, 66 insertions, 6 deletions
diff --git a/rumba/model.py b/rumba/model.py
index 9fbda57..7f65098 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -38,11 +38,17 @@ logger = log.get_logger(__name__)
# @exp_name [string] experiment name
#
class Testbed:
- def __init__(self, exp_name, username, password, proj_name):
+ def __init__(self,
+ exp_name,
+ username,
+ password,
+ proj_name,
+ http_proxy=None):
self.username = username
self.password = password
self.proj_name = proj_name
self.exp_name = exp_name
+ self.http_proxy = http_proxy
@abc.abstractmethod
def swap_in(self, experiment):
diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py
index f9c715f..eaca03a 100644
--- a/rumba/prototypes/irati.py
+++ b/rumba/prototypes/irati.py
@@ -79,7 +79,7 @@ class Experiment(mod.Experiment):
cmds.append("cd ~/irati && sudo ./install-from-scratch")
for node in self.nodes:
- ssh.execute_commands(self.testbed, node.ssh_config,
+ ssh.execute_proxy_commands(self.testbed, node.ssh_config,
cmds, time_out=None)
def setup(self):
diff --git a/rumba/prototypes/rlite.py b/rumba/prototypes/rlite.py
index 625668d..de2ba52 100644
--- a/rumba/prototypes/rlite.py
+++ b/rumba/prototypes/rlite.py
@@ -38,6 +38,10 @@ class Experiment(mod.Experiment):
ssh.execute_commands(self.testbed, node.ssh_config,
cmds, time_out=None)
+ def execute_proxy_commands(self, node, cmds):
+ ssh.execute_proxy_commands(self.testbed, node.ssh_config,
+ cmds, time_out=None)
+
# Prepend sudo to all commands if the user is not 'root'
def may_sudo(self, cmds):
if self.testbed.username != 'root':
@@ -117,17 +121,17 @@ class Experiment(mod.Experiment):
def install_prototype(self):
logger.info("installing rlite on all nodes")
cmds = ["sudo apt-get update",
- "export https_proxy=\"https://proxy.atlantis.ugent.be:8080\"; sudo -E apt-get install g++ gcc cmake "
+ "sudo -E apt-get install g++ gcc cmake "
"linux-headers-$(uname -r) "
"protobuf-compiler libprotobuf-dev git --yes",
"rm -rf ~/rlite",
- "cd ~; export https_proxy=\"https://proxy.atlantis.ugent.be:8080\"; git clone https://github.com/vmaffione/rlite",
+ "cd ~; git clone https://github.com/vmaffione/rlite",
"cd ~/rlite && ./configure && make && sudo make install",
"cd ~/rlite && sudo make depmod"
]
for node in self.nodes:
- self.execute_commands(node, cmds)
+ self.execute_proxy_commands(node, cmds)
logger.info("installation complete")
def bootstrap_prototype(self):
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index cb36910..f8ba03b 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -43,6 +43,51 @@ 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
+ if proxy is not None:
+ proxy_command = 'export http_proxy=' + proxy + '; ' \
+ + 'export https_proxy=' + proxy + ';'
+ new_commands.append(proxy_command + ' ' + command)
+ else:
+ new_commands.append(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
diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py
index 5394146..b1fc5ef 100644
--- a/rumba/testbeds/jfed.py
+++ b/rumba/testbeds/jfed.py
@@ -38,7 +38,12 @@ class Testbed(mod.Testbed):
proj_name="ARCFIRE", authority="wall2.ilabt.iminds.be",
image=None):
passwd = getpass.getpass(prompt="Password for certificate file: ")
- mod.Testbed.__init__(self, exp_name, username, passwd, proj_name)
+ mod.Testbed.__init__(self,
+ exp_name,
+ username,
+ passwd,
+ proj_name,
+ http_proxy="https://proxy.atlantis.ugent.be:8080")
self.authority = "urn:publicid:IDN+" + authority + "+authority+cm"
self.auth_name = authority
self.cert_file = cert_file