aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rumba/ssh_support.py2
-rw-r--r--rumba/storyboard.py32
2 files changed, 25 insertions, 9 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index 7623f6d..1a95d7f 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -338,7 +338,7 @@ def copy_files_from_testbed(testbed, ssh_config, paths,
if sudo:
cmd = 'chmod a+rw %s' % (" ".join(paths))
if ssh_config.username != 'root':
- cmd = "sudo %s" % command
+ cmd = "sudo %s" % cmd
execute_command(testbed, ssh_config, cmd)
if ssh_config.client is None:
diff --git a/rumba/storyboard.py b/rumba/storyboard.py
index 8570690..922b200 100644
--- a/rumba/storyboard.py
+++ b/rumba/storyboard.py
@@ -87,7 +87,7 @@ class Client(_SBEntity):
return cls.current_id
def __init__(self, ap, nodes=None, options=None,
- shutdown="kill <pid>", c_id=None):
+ shutdown="kill <pid>", c_id=None, as_root=False):
"""
:param ap: the application binary/command to be run
:type ap: `str`
@@ -101,6 +101,9 @@ class Client(_SBEntity):
:type shutdown: `str`
:param c_id: the ID used to reference to this instance
:type c_id: `str`
+ :param as_root: if true, the server app will be started
+ with root permissions
+ :type as_root: `bool`
"""
self.ap = ap
e_id = c_id if c_id is not None else self.ap.replace(' ', '_')
@@ -112,6 +115,7 @@ class Client(_SBEntity):
nodes = []
self.nodes = nodes
self.shutdown = shutdown
+ self.as_root = as_root
def add_node(self, node):
"""
@@ -154,14 +158,15 @@ class Client(_SBEntity):
self.startup,
duration,
node,
- self.shutdown
+ self.shutdown,
+ self.as_root
)
class ClientProcess(_SBEntity):
"""Class representing a running client application process on a node"""
def __init__(self, proc_id, ap_id, startup, duration,
- node, shutdown="kill <pid>"):
+ node, shutdown="kill <pid>", as_root=False):
"""
:param proc_id: the ID used to identify this instance
@@ -178,6 +183,9 @@ class ClientProcess(_SBEntity):
:type node: `rumba.model.Node`
:param shutdown: the command used to stop this process
:type shutdown: `str`
+ :param as_root: if true, the client app will be started
+ with root permissions
+ :type as_root: `bool`
"""
super(ClientProcess, self).__init__(proc_id)
self.ap_id = ap_id
@@ -188,6 +196,7 @@ class ClientProcess(_SBEntity):
self.node = node
self.pid = None
self.shutdown = shutdown
+ self.as_root = as_root
def run(self):
"""Starts this process"""
@@ -200,13 +209,15 @@ class ClientProcess(_SBEntity):
self.ap_id, self.node.name, self.duration
)
- start_cmd = "./startup.sh %s %s" % (
+ startup = self.startup.replace("<duration>", str(self.duration))
+ cmd = "./startup.sh %s %s" % (
self.id,
- self.startup.replace("<duration>", str(self.duration)),
+ startup,
)
+
self.running = True
try:
- self.pid = self.node.execute_command(start_cmd)
+ self.pid = self.node.execute_command(cmd, as_root=self.as_root)
except ssh_support.SSHException:
logger.warning('Could not start client %s on node %s.',
self.ap_id, self.node.name)
@@ -245,7 +256,8 @@ class Server(_SBEntity):
def __init__(self, ap, arrival_rate, mean_duration,
options=None, max_clients=float('inf'),
- clients=None, nodes=None, min_duration=2, s_id=None):
+ clients=None, nodes=None, min_duration=2,
+ s_id=None, as_root=False):
"""
:param ap: the application binary or command which should be run
@@ -272,6 +284,9 @@ class Server(_SBEntity):
:type min_duration: `float`
:param s_id: the ID used to identify this instance
:type s_id: `str`
+ :param as_root: if true, the server app will be started
+ with root permissions
+ :type as_root: `bool`
"""
self.ap = ap
e_id = s_id if s_id is not None else self.ap.replace(' ', '_')
@@ -289,6 +304,7 @@ class Server(_SBEntity):
# in seconds
self.pids = {}
self.min_duration = min_duration
+ self.as_root = as_root
def add_client(self, client):
"""
@@ -403,7 +419,7 @@ class Server(_SBEntity):
self.id, node.name
)
try:
- self.pids[node] = node.execute_command(cmd_2)
+ self.pids[node] = node.execute_command(cmd_2, as_root=self.as_root)
except ssh_support.SSHException:
logger.warn('Could not start server %s on node %s.',
self.id, node.name)