When adding a new node to the cluster, the monitoring daemon should be
immediately started there as well. Up to now, it was only started on the
master node.

Signed-off-by: Michele Tartara <[email protected]>
---
 lib/client/gnt_node.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/lib/client/gnt_node.py b/lib/client/gnt_node.py
index 8fd28df..fc9a662 100644
--- a/lib/client/gnt_node.py
+++ b/lib/client/gnt_node.py
@@ -30,6 +30,7 @@ import itertools
 import errno
 
 from ganeti.cli import *
+from ganeti import _autoconf
 from ganeti import cli
 from ganeti import bootstrap
 from ganeti import opcodes
@@ -269,8 +270,33 @@ def AddNode(opts, args):
   if opts.node_setup:
     _SetupSSH(opts, cluster_name, node)
 
+  srun = ssh.SshRunner(cluster_name)
+
+  # stop the monitoring daemon (if it's already running)
+  if _autoconf.ENABLE_MOND:
+    scmd = srun.BuildCmd(node, constants.SSH_LOGIN_USER,
+                         " ".join([pathutils.DAEMON_UTIL, "stop",
+                                   constants.MOND]))
+    result = utils.RunCmd(scmd)
+    if result.failed:
+      raise errors.OpExecError("Could not stop the monitoring daemon,"
+                               " command %s"
+                               " had exitcode %s and error '%s'" %
+                               (result.cmd, result.exit_code, result.output))
+
   bootstrap.SetupNodeDaemon(opts, cluster_name, node)
 
+  # start the monitoring deamon now that the node daemon is configured
+  if _autoconf.ENABLE_MOND:
+    scmd = srun.BuildCmd(node, constants.SSH_LOGIN_USER,
+                         " ".join([pathutils.DAEMON_UTIL, "start",
+                                   constants.MOND]))
+    result = utils.RunCmd(scmd)
+    if result.failed:
+      raise errors.OpExecError("Could not start the monitoring daemon, command 
%s"
+                               " had exitcode %s and error '%s'" %
+                               (result.cmd, result.exit_code, result.output))
+
   if opts.disk_state:
     disk_state = utils.FlatToDict(opts.disk_state)
   else:
-- 
1.8.2.1

Reply via email to