From f75a6d9b31479060dd1d1a52102a714ae7c48154 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Thu, 1 Jun 2017 15:17:59 +0200 Subject: model: remove registration and bindings Fixes #7 --- rumba/prototypes/irati.py | 8 +------- rumba/prototypes/ouroboros.py | 25 ------------------------- 2 files changed, 1 insertion(+), 32 deletions(-) (limited to 'rumba/prototypes') diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py index e24dd60..f9c715f 100644 --- a/rumba/prototypes/irati.py +++ b/rumba/prototypes/irati.py @@ -228,16 +228,10 @@ class Experiment(mod.Experiment): next_vlan += 10 self.shim2vlan[dif.name] = vlan - # TODO: what format are the mappings registered in? Is this ok? - app_mappings = [] - for node in self.nodes: - app_mappings += [{'name': app, 'dif': self.dif_name(dif)} - for app in node.registrations - for dif in node.registrations[app]] - # If some app directives were specified, use those to build da.map. # Otherwise, assume the standard applications are to be mapped in # the DIF with the highest rank. + app_mappings = [] if len(app_mappings) == 0: if len(self.dif_ordering) > 0: for adm in \ diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 9c164e7..01b8b72 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -50,27 +50,6 @@ class Experiment(mod.Experiment): ssh.execute_commands(self.testbed, node.ssh_config, cmds, time_out=None) - def bind_names(self): - for node in self.nodes: - cmds = list() - for name, ap in node.bindings.items(): - cmds.append("irm b ap " + ap + " n " + name) - - ssh.execute_commands(self.testbed, node.ssh_config, - cmds, time_out=None) - - def reg_names(self): - for node in self.nodes: - cmds = list() - for name, difs in node.registrations.items(): - cmd = "irm r n " + name - for dif in difs: - cmd += " dif " + dif.name - cmds.append(cmd) - - ssh.execute_commands(self.testbed, node.ssh_config, cmds, - time_out=None) - def create_ipcps(self): for node in self.nodes: cmds = list() @@ -147,12 +126,8 @@ class Experiment(mod.Experiment): def bootstrap_prototype(self): logger.info("Starting IRMd on all nodes...") self.setup_ouroboros() - logger.info("Binding names...") - self.bind_names() logger.info("Creating IPCPs") self.create_ipcps() logger.info("Enrolling IPCPs...") self.enroll_ipcps() - logger.info("Registering names...") - self.reg_names() logger.info("All done, have fun!") -- cgit v1.2.3 From 30dbd8b5493480d2c302380735083c2d9b8f8260 Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Thu, 1 Jun 2017 16:43:03 +0200 Subject: model: added proxy field. ssh: added execute_proxy_commands --- rumba/model.py | 10 +++++++++- rumba/prototypes/irati.py | 2 +- rumba/ssh_support.py | 42 ++++++++++++++++++++++++++++++++++++++++++ rumba/testbeds/jfed.py | 7 ++++++- 4 files changed, 58 insertions(+), 3 deletions(-) (limited to 'rumba/prototypes') diff --git a/rumba/model.py b/rumba/model.py index 285d937..27fcc23 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -38,11 +38,19 @@ 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 + if http_proxy is None: + http_proxy = "" + 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 e24dd60..894593b 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/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 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 -- cgit v1.2.3 From d1b49132f669cf1df4367103ebad63029793a127 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Thu, 1 Jun 2017 17:24:25 +0200 Subject: model: Experiment: add prototype_name() --- rumba/model.py | 8 ++++++-- rumba/prototypes/irati.py | 3 +++ rumba/prototypes/ouroboros.py | 3 +++ rumba/prototypes/rlite.py | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'rumba/prototypes') diff --git a/rumba/model.py b/rumba/model.py index 9fbda57..8631a9d 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -514,11 +514,15 @@ class Experiment: @abc.abstractmethod def install_prototype(self): - raise Exception('run_prototype() method not implemented') + raise Exception('install_prototype() method not implemented') @abc.abstractmethod def bootstrap_prototype(self): - raise Exception('run_prototype() method not implemented') + raise Exception('bootstrap_prototype() method not implemented') + + @abc.abstractmethod + def prototype_name(self): + raise Exception('prototype_name() method not implemented') def swap_in(self): # Realize the experiment testbed (testbed-specific) diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py index f9c715f..750d6aa 100644 --- a/rumba/prototypes/irati.py +++ b/rumba/prototypes/irati.py @@ -38,6 +38,9 @@ logger = log.get_logger(__name__) # An experiment over the IRATI implementation class Experiment(mod.Experiment): + def prototype_name(self): + return 'irati' + @staticmethod def real_sudo(s): return 'sudo ' + s diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 01b8b72..9ac1425 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -32,6 +32,9 @@ class Experiment(mod.Experiment): def __init__(self, testbed, nodes=None): mod.Experiment.__init__(self, testbed, nodes) + def prototype_name(self): + return 'ouroboros' + def setup_ouroboros(self): for node in self.nodes: ssh.execute_command(self.testbed, node.ssh_config, diff --git a/rumba/prototypes/rlite.py b/rumba/prototypes/rlite.py index 625668d..098125a 100644 --- a/rumba/prototypes/rlite.py +++ b/rumba/prototypes/rlite.py @@ -34,6 +34,9 @@ class Experiment(mod.Experiment): def __init__(self, testbed, nodes=None): mod.Experiment.__init__(self, testbed, nodes) + def prototype_name(self): + return 'rlite' + def execute_commands(self, node, cmds): ssh.execute_commands(self.testbed, node.ssh_config, cmds, time_out=None) -- cgit v1.2.3 From c92408dc0a74e2ca1ef47cc721ad41dff614aaa4 Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Thu, 1 Jun 2017 17:34:53 +0200 Subject: Model: corrected no-proxy case. rlite: removed hardcoded proxy --- rumba/model.py | 2 -- rumba/prototypes/rlite.py | 10 +++++++--- rumba/ssh_support.py | 9 ++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'rumba/prototypes') diff --git a/rumba/model.py b/rumba/model.py index 27fcc23..6508c86 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -48,8 +48,6 @@ class Testbed: self.password = password self.proj_name = proj_name self.exp_name = exp_name - if http_proxy is None: - http_proxy = "" self.http_proxy = http_proxy @abc.abstractmethod 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 93a48f8..f8ba03b 100644 --- a/rumba/ssh_support.py +++ b/rumba/ssh_support.py @@ -59,9 +59,12 @@ def execute_proxy_commands(testbed, ssh_config, commands, time_out=3): 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) + 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) -- cgit v1.2.3