From 81ca2217d34b70e6a3ef7385261be38958cb4a42 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 13 Apr 2017 16:33:26 +0200 Subject: rumba: Add ProxyCommand for jFed This adds a proxy command for the jFed testbed so that it can be accessed when someone does not have IPv6. --- rumba/model.py | 3 ++- rumba/ssh_support.py | 16 ++++++++++++++-- rumba/testbeds/jfed.py | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rumba/model.py b/rumba/model.py index c2c4cfa..4ada554 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -128,9 +128,10 @@ class NormalDIF(DIF): # SSH Configuration # class SSHConfig: - def __init__(self, hostname, port=22): + def __init__(self, hostname, port=22, proxycommand=None): self.hostname = hostname self.port = port + self.proxycommand = proxycommand # A node in the experiment # diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py index c6615c3..2c9d6d0 100644 --- a/rumba/ssh_support.py +++ b/rumba/ssh_support.py @@ -49,10 +49,16 @@ def execute_commands(testbed, ssh_config, commands, time_out=3): ''' ssh_client = get_ssh_client() + if ssh_config.proxycommand != None: + proxy = paramiko.ProxyCommand(ssh_config.proxycommand) + else: + proxy = None + try: ssh_client.connect(ssh_config.hostname, ssh_config.port, testbed.username, testbed.password, - look_for_keys=True, timeout=time_out) + look_for_keys=True, timeout=time_out, + sock=proxy) for command in commands: print("%s@%s:%s >> %s" % (testbed.username, ssh_config.hostname, ssh_config.port, command)) @@ -98,11 +104,17 @@ def copy_file_to_testbed(testbed, ssh_config, text, file_name): ''' ssh_client = get_ssh_client() + if ssh_config.proxycommand != None: + proxy = paramiko.ProxyCommand(ssh_config.proxycommand) + else: + proxy = None + try: ssh_client.connect(ssh_config.hostname, ssh_config.port, testbed.username, testbed.password, - look_for_keys=True) + look_for_keys=True, + sock=proxy) cmd = "touch " + file_name + \ "; chmod a+rwx " + file_name diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py index 0dfc904..f09bb4e 100644 --- a/rumba/testbeds/jfed.py +++ b/rumba/testbeds/jfed.py @@ -113,6 +113,11 @@ class Testbed(mod.Testbed): auth_name_r = self.auth_name.replace(".", "-") node.ssh_config.hostname = node.name + "." + self.exp_name + "." + \ auth_name_r + "." + self.auth_name + node.ssh_config.proxycommand = "ssh -i '" + self.cert_file + \ + "' -o StrictHostKeyChecking=no " + \ + self.username + \ + "@bastion.test.iminds.be nc " + \ + node.ssh_config.hostname + " 22" subprocess.call(["java", "-jar", self.jfed_jar, "create", "-S", \ self.proj_name, "--rspec", \ -- cgit v1.2.3