From 24bed306b5a67fc682b04cae017b0d0f3ac55a00 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 16 Mar 2018 16:53:45 +0100 Subject: storyboard: Add link and node up and down events This adds link and node up and down events to the storyboard, which can be called by a user on a specific time. The user needs to pass the time and the shim Ethernet for a link up or down event and a time and a node for the node up or down event. The interfaces in that layer or on that node will then be brought down. Implements #31 --- rumba/model.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'rumba/model.py') diff --git a/rumba/model.py b/rumba/model.py index 1f47861..39528be 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -346,9 +346,14 @@ class Node(object): time_out ) - def execute_command(self, command, time_out=3, use_proxy=False): + def execute_command(self, command, time_out=3, + use_proxy=False, as_root=False): # Ssh_config is used twice since it doubles as testbed info # (it holds fields username and password) + if as_root: + if self.ssh_config.username != 'root': + command = "sudo %s" % command + if use_proxy: return ssh_support.execute_proxy_command( self.ssh_config, @@ -406,6 +411,10 @@ class Node(object): sudo=sudo ) + def set_link_state(self, ipcp, state): + self.execute_command('ip link set dev ' + ipcp.ifname + ' ' + state, + as_root=True) + # Base class representing an IPC Process to be created in the experiment # -- cgit v1.2.3