aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2021-07-10 05:41:12 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2021-07-10 05:41:12 +0200
commitb92f65ece3cd38365bdfe11a82780913adee8ddb (patch)
tree7514e4358cd46980f6a7b7c8e4aba1d3f808bd79
parentc069a24e2587bf7be8ebbb418c7e987dd8dc4930 (diff)
downloadrumba-b92f65ece3cd38365bdfe11a82780913adee8ddb.zip
rumba-b92f65ece3cd38365bdfe11a82780913adee8ddb.tar.gz
storyboard: Allow run_command on multiple nodes
It can now take a list of node names. Also fixes sudo in ssh_support, which I accidentally broke in the previous commit.
-rw-r--r--rumba/ssh_support.py2
-rw-r--r--rumba/storyboard.py29
2 files changed, 18 insertions, 13 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index e23a18e..06e7699 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -406,7 +406,7 @@ def aptitude_install(testbed, node, packages):
return s
else:
def sudo(s):
- return 'sudo' + s
+ return 'sudo ' + s
package_install = " DEBIAN_FRONTEND=noninteractive apt-get install "
for package in packages:
diff --git a/rumba/storyboard.py b/rumba/storyboard.py
index c6da6cb..6d9739c 100644
--- a/rumba/storyboard.py
+++ b/rumba/storyboard.py
@@ -729,25 +729,30 @@ class StoryBoard(_SBEntity):
action = functools.partial(self.run_command, node, command)
self._script.add_event(Event(action, ev_time=t))
- def run_command(self, node, command):
+ def run_command(self, nodes, command):
"""
- Runs a command (or several) on a given node, immediately.
+ Runs a command (or several) on a given (set of) node(s), immediately.
- :param node: the node on which the command should be run
- :type node: `rumba.model.Node` or `str`
+ :param nodes: the nodes on which the command should be run
+ :type nodes: `rumba.model.Node` or `str` or a list of these
:param command: the command(s) to be run
:type command: `str` or `list` of `str`
"""
if self.experiment is None:
raise ValueError("Experiment needed to run commands.")
- if isinstance(node, str):
- node = self.node_map[node]
- if node not in self.experiment.nodes:
- raise ValueError('Cannot run command on node %s, '
- 'not in experiment.' % (node.name,))
- if isinstance(command, str):
- command = [command]
- node.execute_commands(command)
+ if not isinstance(nodes, list):
+ _nodes = [nodes]
+ else:
+ _nodes = nodes
+ for _node in _nodes:
+ if isinstance(_node, str):
+ _node = self.node_map[_node]
+ if _node not in self.experiment.nodes:
+ raise ValueError('Cannot run command on node %s, '
+ 'not in experiment.' % (_node.name,))
+ if isinstance(command, str):
+ command = [command]
+ _node.execute_commands(command)
def add_event(self, event):
"""