aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmaffione <v.maffione@gmail.com>2017-04-21 09:38:20 +0000
committervmaffione <v.maffione@gmail.com>2017-04-21 09:38:20 +0000
commit778bd3a1c3f625767c00688faa37af388a054f94 (patch)
treecec1214e3f3226c717f8b94e67661f8fac7fe36c
parentee2f6e5c21c0ba94048dbf1c86024e3181718fc2 (diff)
parent009c8ff7570105a79278559202fdd46616b83a92 (diff)
downloadrumba-778bd3a1c3f625767c00688faa37af388a054f94.tar.gz
rumba-778bd3a1c3f625767c00688faa37af388a054f94.zip
Merge branch 'split' into 'master'
model: Split experiment run() See merge request !37
-rwxr-xr-xexamples/example.py6
-rwxr-xr-xexamples/two-layers.py6
-rw-r--r--rumba/model.py21
-rw-r--r--rumba/prototypes/irati.py46
-rw-r--r--rumba/prototypes/ouroboros.py17
-rw-r--r--rumba/prototypes/rlite.py30
-rwxr-xr-xtools/democonf2rumba.py7
7 files changed, 87 insertions, 46 deletions
diff --git a/examples/example.py b/examples/example.py
index 54ecd37..8d91102 100755
--- a/examples/example.py
+++ b/examples/example.py
@@ -40,4 +40,8 @@ exp = rl.Experiment(tb, nodes = [a, b])
print(exp)
-exp.run()
+try:
+ exp.swap_in()
+ exp.bootstrap_prototype()
+finally:
+ exp.swap_out()
diff --git a/examples/two-layers.py b/examples/two-layers.py
index 9032588..fff3866 100755
--- a/examples/two-layers.py
+++ b/examples/two-layers.py
@@ -52,4 +52,8 @@ exp = rl.Experiment(tb, nodes = [a, b, c, d])
print(exp)
-exp.run()
+try:
+ exp.swap_in()
+ exp.bootstrap_prototype()
+finally:
+ exp.swap_out()
diff --git a/rumba/model.py b/rumba/model.py
index 0d93fcd..d219edb 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -529,16 +529,17 @@ class Experiment:
self.compute_ipcps()
@abc.abstractmethod
- def run_prototype(self):
+ def install_prototype(self):
raise Exception('run_prototype() method not implemented')
- def run(self):
- try:
- # Realize the experiment testbed (testbed-specific)
- self.testbed.swap_in(self)
+ @abc.abstractmethod
+ def bootstrap_prototype(self):
+ raise Exception('run_prototype() method not implemented')
+
+ def swap_in(self):
+ # Realize the experiment testbed (testbed-specific)
+ self.testbed.swap_in(self)
- # Run the experiment using the prototype (prototype-specific)
- self.run_prototype()
- finally:
- # No matter what happens, undo the testbed (testbed-specific)
- self.testbed.swap_out(self)
+ def swap_out(self):
+ # Undo the testbed (testbed-specific)
+ self.testbed.swap_out(self)
diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py
index 0d40580..f012512 100644
--- a/rumba/prototypes/irati.py
+++ b/rumba/prototypes/irati.py
@@ -65,23 +65,26 @@ class Experiment(mod.Experiment):
def conf_dir(self, path):
return os.path.join(self._conf_dir, path)
+ def install(self):
+ """Installs IRATI on the nodes."""
+ cmds = list()
+
+ cmds.append("sudo apt-get update")
+ cmds.append("sudo apt-get install g++ gcc "
+ "protobuf-compiler libprotobuf-dev git --yes")
+ cmds.append("sudo rm -rf ~/irati")
+ cmds.append("cd && git clone https://github.com/IRATI/stack irati")
+ cmds.append("cd ~/irati && sudo ./install-from-scratch")
+
+ for node in self.nodes:
+ ssh.execute_commands(self.testbed, node.ssh_config,
+ cmds, time_out=None)
+
def setup(self):
- """Installs IRATI on the vms."""
- setup_irati = False
- if setup_irati:
- cmds = list()
-
- cmds.append("sudo apt-get update")
- cmds.append("sudo apt-get install g++ gcc "
- "protobuf-compiler libprotobuf-dev git --yes")
- cmds.append("sudo rm -rf ~/irati")
- cmds.append("cd && git clone https://github.com/IRATI/stack irati")
- cmds.append("cd ~/irati && sudo ./install-from-scratch")
- cmds.append("sudo nohup ipcm &> ipcm.log &")
-
- for node in self.nodes:
- ssh.execute_commands(self.testbed, node.ssh_config,
- cmds, time_out=None)
+ for node in self.nodes:
+ ssh.execute_command(self.testbed, node.ssh_config,
+ "sudo nohup ipcm &> ipcm.log &",
+ time_out=None)
def bootstrap_network(self):
"""Creates the network by enrolling and configuring the nodes"""
@@ -89,7 +92,12 @@ class Experiment(mod.Experiment):
self.process_node(node)
self.enroll_nodes()
- def run_prototype(self):
+ def install_prototype(self):
+ print("irati: installing")
+ self.install()
+ print("irati: done installing")
+
+ def bootstrap_prototype(self):
print("irati: setting up")
self.setup()
print("irati: software initialized on all nodes")
@@ -102,8 +110,8 @@ class Experiment(mod.Experiment):
"""
Installs the configuration and boots up rina on a node
:type node: mod.Node
- :param node:
- :return:
+ :param node:
+ :return:
"""
name = node.name
diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py
index 4fdacd6..4ebeea8 100644
--- a/rumba/prototypes/ouroboros.py
+++ b/rumba/prototypes/ouroboros.py
@@ -28,18 +28,22 @@ class Experiment(mod.Experiment):
mod.Experiment.__init__(self, testbed, nodes)
def setup_ouroboros(self):
+ for node in self.nodes:
+ ssh.execute_command(self.testbed, node.ssh_config,
+ "sudo nohup irmd > /dev/null &",
+ time_out=None)
+
+ def install_ouroboros(self):
cmds = list()
cmds.append("sudo apt-get update")
cmds.append("sudo apt-get install cmake protobuf-c-compiler git --yes")
cmds.append("sudo rm -r ~/ouroboros/build")
cmds.append("cd ~/ouroboros; sudo ./install_debug.sh /")
- cmds.append("sudo nohup irmd > /dev/null &")
for node in self.nodes:
ssh.execute_commands(self.testbed, node.ssh_config,
cmds, time_out=None)
- return
def bind_names(self):
for node in self.nodes:
@@ -131,8 +135,13 @@ class Experiment(mod.Experiment):
cmds, time_out = None)
time.sleep(2)
- def run_prototype(self):
- print("Setting up Ouroboros...")
+ def install_prototype(self):
+ print("Installing Ouroboros...")
+ self.install_ouroboros()
+ print("Installed on all nodes...")
+
+ def bootstrap_prototype(self):
+ print("Starting IRMd on all nodes...")
self.setup_ouroboros()
print("Binding names...")
self.bind_names()
diff --git a/rumba/prototypes/rlite.py b/rumba/prototypes/rlite.py
index 9568d7e..4221f2a 100644
--- a/rumba/prototypes/rlite.py
+++ b/rumba/prototypes/rlite.py
@@ -35,15 +35,6 @@ class Experiment(mod.Experiment):
def init(self):
cmds = []
- if False: # ubuntu
- cmds.append("apt-get update")
- cmds.append("apt-get install g++ gcc cmake "
- "linux-headers-$(uname -r) "
- "protobuf-compiler libprotobuf-dev git --yes")
- cmds.append("rm -rf ~/rlite")
- cmds.append("cd ~; git clone https://github.com/vmaffione/rlite")
- cmds.append("cd ~/rlite && ./configure && make && sudo make install")
-
# Load kernel modules
cmds.append("modprobe rlite")
cmds.append("modprobe rlite-normal")
@@ -57,6 +48,20 @@ class Experiment(mod.Experiment):
for node in self.nodes:
self.execute_commands(node, cmds)
+ def install(self):
+ cmds = []
+
+ cmds.append("apt-get update")
+ cmds.append("apt-get install g++ gcc cmake "
+ "linux-headers-$(uname -r) "
+ "protobuf-compiler libprotobuf-dev git --yes")
+ cmds.append("rm -rf ~/rlite")
+ cmds.append("cd ~; git clone https://github.com/vmaffione/rlite")
+ cmds.append("cd ~/rlite && ./configure && make && sudo make install")
+
+ for node in self.nodes:
+ self.execute_commands(node, cmds)
+
def create_ipcps(self):
for node in self.nodes:
cmds = []
@@ -109,7 +114,12 @@ class Experiment(mod.Experiment):
"%(lower_dif)s %(enroller)s" % d
self.execute_commands(e['enrollee'], [cmd])
- def run_prototype(self):
+ def install_prototype(self):
+ print("rlite: installing")
+ self.install()
+ print("rlite: installed")
+
+ def bootstrap_prototype(self):
print("rlite: setting up")
self.init()
print("rlite: software initialized on all nodes")
diff --git a/tools/democonf2rumba.py b/tools/democonf2rumba.py
index c708e8e..9d909c7 100755
--- a/tools/democonf2rumba.py
+++ b/tools/democonf2rumba.py
@@ -123,7 +123,12 @@ def make_experiment(filename, experiment_class, experiment_kwargs,
experiment_kwargs['testbed'] = testbed
experiment_kwargs['nodes'] = parsed_nodes
- return experiment_class(**experiment_kwargs).run()
+ exp = experiment_class(**experiment_kwargs)
+ try:
+ exp.swap_in()
+ exp.bootstrap_prototype()
+ finally:
+ exp.swap_out()
def setup_testbed_common_args(t_p):