aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-06-12 16:40:11 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-06-12 16:40:11 +0200
commitcd34f0b66e7981490bd50752abe68ea11481963c (patch)
treed65a196c996dd8ec207789601f8ce8e3c9b5fa5f
parentb1354ee6dfc5d77b631348356fb823d1c1a85e02 (diff)
downloadrumba-cd34f0b66e7981490bd50752abe68ea11481963c.tar.gz
rumba-cd34f0b66e7981490bd50752abe68ea11481963c.zip
elements: Add terminate prototype and reboot nodes
This adds functions to terminate the prototype gracefully or forcefully, and to reboot all nodes in the experiment. This is useful when running the experiment interactively, so swapping out and back in is not always required.
-rw-r--r--rumba/elements/experimentation.py17
-rw-r--r--rumba/prototypes/ouroboros.py30
-rw-r--r--rumba/utils.py7
3 files changed, 43 insertions, 11 deletions
diff --git a/rumba/elements/experimentation.py b/rumba/elements/experimentation.py
index 1c27dff..d0910a6 100644
--- a/rumba/elements/experimentation.py
+++ b/rumba/elements/experimentation.py
@@ -503,7 +503,7 @@ class Experiment(object):
raise Exception('prototype_name() method not implemented')
@abc.abstractmethod
- def _terminate_prototype(self):
+ def _terminate_prototype(self, force=False):
raise Exception('terminate_prototype() method not implemented')
def swap_in(self):
@@ -521,8 +521,6 @@ class Experiment(object):
Swap the experiment out of the testbed.
"""
start = time.time()
- # Terminate prototype gracefully
- self._terminate_prototype()
for node in self.nodes:
if node.ssh_config.client is not None:
node.ssh_config.client.close()
@@ -533,6 +531,19 @@ class Experiment(object):
end = time.time()
logger.info("Swap-out took %.2f seconds", end - start)
+ def terminate_prototype(self, force=False):
+ """
+ Terminate the prototype in the experiment.
+ """
+ self._terminate_prototype()
+
+ def reboot_nodes(self):
+ """
+ Reboot all nodes in the experiment.
+ """
+ for node in self.nodes:
+ node.execute_command('reboot', as_root=True)
+
@abc.abstractmethod
def export_dif_bandwidth(self, filename, dif):
raise Exception('Export DIF bandwidth method not implemented')
diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py
index 643754f..1ca5e6d 100644
--- a/rumba/prototypes/ouroboros.py
+++ b/rumba/prototypes/ouroboros.py
@@ -169,9 +169,7 @@ class Experiment(mod.Experiment):
"git clone -b " + self.git_branch + " " + self.git_repo + \
" " + fs_loc,
"cd " + fs_loc + " && mkdir build && cd build && " +
- "cmake -DCMAKE_BUILD_TYPE=Debug -DIPCP_FLOW_STATS=True " +
- "-DCONNECT_TIMEOUT=60000 -DIPCP_CONN_WAIT_DIR=True " +
- "-DREG_TIMEOUT=60000 -DQUERY_TIMEOUT=4000 .. && " +
+ "cmake .. && " +
"sudo make install -j$(nproc)"]
names = []
@@ -199,7 +197,7 @@ class Experiment(mod.Experiment):
if isinstance(self.testbed, local.Testbed):
cmd += " type local layer " + ipcp.dif.name
else:
- cmd += " type eth-llc dev " + ipcp.ifname
+ cmd += " type eth-dix dev " + ipcp.ifname
cmd += " layer " + ipcp.dif.name
elif isinstance(ipcp.dif, mod.NormalDIF):
cmd += " type normal"
@@ -299,10 +297,28 @@ class Experiment(mod.Experiment):
logger.info("All done, have fun!")
- def _terminate_prototype(self):
+ def _terminate_prototype(self, force=False):
+ cmds = list()
+
+ if force:
+ kill = 'killall -9 '
+ cmds.append(kill + 'irmd')
+ cmds.append(kill + 'ipcpd-normal')
+ cmds.append(kill + 'ipcpd-shim-eth-llc')
+ cmds.append(kill + 'ipcpd-local')
+ cmds.append('kill -9 $(ps axjf | grep \'sudo irmd\' '
+ '| grep -v grep | cut -f4 -d " "')
+ else:
+ cmds.append('killall -15 irmd')
+
+ logger.info("Killing Ouroboros...")
if isinstance(self.testbed, local.Testbed):
- logger.info("Killing IRMd...")
- subprocess.check_call('sudo killall -15 irmd'.split())
+ cmds = list(map(lambda c: "sudo %s" % (c,), cmds))
+ for cmd in cmds:
+ subprocess.check_call(cmd.split())
+ else:
+ for node in self.nodes:
+ node.execute_commands(cmds, time_out=None, as_root=True)
def destroy_dif(self, dif):
for ipcp in dif.ipcps:
diff --git a/rumba/utils.py b/rumba/utils.py
index 88ea0d3..822deb3 100644
--- a/rumba/utils.py
+++ b/rumba/utils.py
@@ -29,6 +29,7 @@ import os
import rumba.log as log
import rumba.model as model
+import rumba.testbeds.local as local
# Fix input reordering
try:
@@ -204,7 +205,11 @@ class ExperimentManager(object):
# Swap out
if do_swap_out:
- self.experiment.swap_out()
+ # Kill prototype in case of local testbed
+ if isinstance(self.experiment.testbed, local.Testbed):
+ self.experiment.terminate_prototype()
+ else:
+ self.experiment.swap_out()
if exc_val is not None:
logger.error('Something went wrong. '
'Got %s: %s',