aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rumba/prototypes/rlite.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/rumba/prototypes/rlite.py b/rumba/prototypes/rlite.py
index a35f2f1..d35c5d5 100644
--- a/rumba/prototypes/rlite.py
+++ b/rumba/prototypes/rlite.py
@@ -38,17 +38,21 @@ class Experiment(mod.Experiment):
ssh.execute_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':
+ for i in range(len(cmds)):
+ cmds[i] = "sudo %s" % cmds[i]
+
def init_nodes(self):
+ # Load kernel modules and start the uipcps daemon
cmds = ["modprobe rlite",
"modprobe rlite-normal",
"modprobe rlite-shim-eth",
"modprobe rlite-shim-udp4",
"modprobe rlite-shim-loopback",
"rlite-uipcps -v DBG -k 0 &> uipcp.log &"]
-
- # Load kernel modules
-
- # Start the uipcps daemon
+ self.may_sudo(cmds)
for node in self.nodes:
self.execute_commands(node, cmds)
@@ -80,6 +84,7 @@ class Experiment(mod.Experiment):
cmds.append("rlite-ctl ipcp-config %s netdev %s"
% (ipcp.name, ipcp.ifname))
+ self.may_sudo(cmds)
self.execute_commands(node, cmds)
def register_ipcps(self):
@@ -91,6 +96,7 @@ class Experiment(mod.Experiment):
cmds.append("rlite-ctl ipcp-register %s %s"
% (ipcp.name, lower.name))
+ self.may_sudo(cmds)
self.execute_commands(node, cmds)
def enroll_ipcps(self):
@@ -103,7 +109,9 @@ class Experiment(mod.Experiment):
}
cmd = "rlite-ctl ipcp-enroll %(enrollee)s %(dif)s "\
"%(lower_dif)s %(enroller)s" % d
- self.execute_commands(e['enrollee'].node, [cmd])
+ cmds = [cmd]
+ self.may_sudo(cmds)
+ self.execute_commands(e['enrollee'].node, cmds)
time.sleep(1)
def install_prototype(self):