From ebdd8624528275311396f90e08632c550cb64a71 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 31 May 2018 14:55:56 +0200 Subject: storyboard: Allow destroying of a DIF This allows the destroying of a DIF while the experiment is running. This to ease the emulation of failures in the network. --- rumba/elements/experimentation.py | 4 ++++ rumba/prototypes/ouroboros.py | 4 ++++ rumba/storyboard.py | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/rumba/elements/experimentation.py b/rumba/elements/experimentation.py index 09cfc84..1ae50f7 100644 --- a/rumba/elements/experimentation.py +++ b/rumba/elements/experimentation.py @@ -478,6 +478,10 @@ class Experiment(object): end = time.time() logger.info("Bootstrap took %.2f seconds", end - start) + @abc.abstractmethod + def destroy_dif(self, dif): + raise Exception('destroy_dif() method not implemented') + @abc.abstractmethod def _install_prototype(self): raise Exception('install_prototype() method not implemented') diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 1402180..a7a7fc9 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -246,3 +246,7 @@ class Experiment(mod.Experiment): if isinstance(self.testbed, local.Testbed): logger.info("Killing IRMd...") subprocess.check_call('sudo killall -15 irmd'.split()) + + def destroy_dif(self, dif): + for ipcp in dif.ipcps: + ipcp.node.execute_command('irm i d n ' + ipcp.name) diff --git a/rumba/storyboard.py b/rumba/storyboard.py index 6b56a92..c652073 100644 --- a/rumba/storyboard.py +++ b/rumba/storyboard.py @@ -1065,6 +1065,22 @@ class StoryBoard(_SBEntity): """ self.schedule_node_state(t, node, 'down') + def schedule_destroy_dif(self, t, dif): + """ + Destroys a DIF at the specified time. + + :param t: the time in the storyboard at which the state + change should happen + :type t: `float` + :param dif: the DIF which should go down + :type dif: `rumba.model.DIF` + """ + if self.experiment is None: + raise ValueError("An experiment is needed to schedule commands.") + + action = functools.partial(self.experiment.destroy_dif, dif) + self.add_event(Event(action, ev_time=t)) + def write_script(self, buffer): """ Writes the script on a (string-oriented) buffer, -- cgit v1.2.3