From 485ab3a152d36a5209fe01f6868472f07b25c99c Mon Sep 17 00:00:00 2001
From: Marco Capitani <m.capitani@nextworks.it>
Date: Tue, 27 Mar 2018 12:54:11 +0200
Subject: storyboard: install startup.sh in all nodes

Before storyboard installed the startup only on the client nodes
(i.e. nodes marked in a Client class). Now Clients could be run
outside of their nodes, hence the patch.
Also, incidentally, fixes an issue with server log-files.
---
 rumba/storyboard.py | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/rumba/storyboard.py b/rumba/storyboard.py
index 61dd8cc..1d6858e 100644
--- a/rumba/storyboard.py
+++ b/rumba/storyboard.py
@@ -275,21 +275,16 @@ class Server(SBEntity):
 
     def run(self):
         for node in self.nodes:
-            logfile = "/tmp/%s_server.log" % self.ap
-            script = r'nohup "$@" > %s 2>&1 & echo "$!"' % (logfile,)
             run_cmd = self.ap + (
                 (" " + self.options) if self.options is not None else ""
             )
-            cmd_1 = "echo '%s' > startup.sh && chmod a+x startup.sh" \
-                    % (script,)
-            cmd_2 = "./startup.sh %s" % (run_cmd,)
+            cmd_2 = "./startup.sh %s %s" % ('server_' + self.id, run_cmd)
             logger.debug(
-                'Starting server %s on node %s with logfile %s.',
-                self.id, node.name, logfile
+                'Starting server %s on node %s.',
+                self.id, node.name
             )
             try:
-                node.execute_command(cmd_1)
-                self.pids[node] = (node.execute_command(cmd_2))
+                self.pids[node] = node.execute_command(cmd_2)
             except ssh_support.SSHException:
                 logger.warn('Could not start server %s on node %s.',
                             self.id, node.name)
@@ -664,8 +659,6 @@ class StoryBoard(SBEntity):
         self._build_nodes_lists()
         logger.debug('Server nodes are: %s.',
                      [x.name for x in self.server_nodes])
-        logger.debug('Client nodes are: %s.',
-                     [x.name for x in self.client_nodes])
         logger.debug('Command list is: %s.', {x: [(y.name, z)
                                                   for y, z in t]
                                               for (x, t)
@@ -673,8 +666,8 @@ class StoryBoard(SBEntity):
         self.start_time = time.time()
         script = r'logname="$1"; shift; nohup "${@}" ' \
                  r'> /tmp/${logname}.rumba.log 2>&1  & echo "$!"'
-        logger.debug("Writing utility startup script on client nodes.")
-        for node in self.client_nodes:
+        logger.debug("Writing utility startup script on nodes.")
+        for node in self.node_map.values():
             node.execute_command(
                 "echo '%s' > startup.sh && chmod a+x startup.sh" % (script,)
             )
-- 
cgit v1.2.3