diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index c52a74ea7fd17955e629ac6837753f3f5b1c0da1..449e010b8f6b9a18bf51bfd86e597a44d9cf2d00 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -407,14 +407,14 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler): """Promote this node to master status. """ - return backend.StartMaster() + return backend.StartMaster(params[0]) @staticmethod def perspective_node_stop_master(params): """Demote this node from master status. """ - return backend.StopMaster() + return backend.StopMaster(params[0]) @staticmethod def perspective_node_leave_cluster(params): diff --git a/lib/backend.py b/lib/backend.py index ca9ac7c12e048030ab8b649ca6ae6976f33b9bcf..b78a5ecc002ba2a75d1658eb475ee131706305ff 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -47,12 +47,13 @@ def _GetSshRunner(): return ssh.SshRunner() -def StartMaster(): +def StartMaster(start_daemons): """Activate local node as master node. - There are two needed steps for this: - - run the master script - - register the cron script + The function will always try activate the IP address of the master + (if someone else has it, then it won't). Then, if the start_daemons + parameter is True, it will also start the master daemons + (ganet-masterd and ganeti-rapi). """ result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "start"]) @@ -65,10 +66,12 @@ def StartMaster(): return True -def StopMaster(): +def StopMaster(stop_daemons): """Deactivate this node as master. - This runs the master stop script. + The function will always try to deactivate the IP address of the + master. Then, if the stop_daemons parameter is True, it will also + stop the master daemons (ganet-masterd and ganeti-rapi). """ result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "stop"]) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 744e2a1ed689a371e60810136c0009cc5a9780e7..5cde39493d19fd0004f64a0c73ea5b660564ce10 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -416,7 +416,7 @@ class LUDestroyCluster(NoHooksLU): """ master = self.sstore.GetMasterNode() - if not rpc.call_node_stop_master(master): + if not rpc.call_node_stop_master(master, False): raise errors.OpExecError("Could not disable the master role") priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) utils.CreateBackup(priv_key) @@ -962,7 +962,7 @@ class LURenameCluster(LogicalUnit): # shutdown the master IP master = ss.GetMasterNode() - if not rpc.call_node_stop_master(master): + if not rpc.call_node_stop_master(master, False): raise errors.OpExecError("Could not disable the master role") try: @@ -985,7 +985,7 @@ class LURenameCluster(LogicalUnit): logger.Error("copy of file %s to node %s failed" % (fname, to_node)) finally: - if not rpc.call_node_start_master(master): + if not rpc.call_node_start_master(master, False): logger.Error("Could not re-enable the master role on the master," " please restart manually.") @@ -1737,7 +1737,7 @@ class LUMasterFailover(LogicalUnit): logger.Info("setting master to %s, old master: %s" % (self.new_master, self.old_master)) - if not rpc.call_node_stop_master(self.old_master): + if not rpc.call_node_stop_master(self.old_master, True): logger.Error("could disable the master role on the old master" " %s, please disable manually" % self.old_master) @@ -1748,7 +1748,7 @@ class LUMasterFailover(LogicalUnit): logger.Error("could not distribute the new simple store master file" " to the other nodes, please check.") - if not rpc.call_node_start_master(self.new_master): + if not rpc.call_node_start_master(self.new_master, True): logger.Error("could not start the master role on the new master" " %s, please check" % self.new_master) feedback_fn("Error in activating the master IP on the new master," diff --git a/lib/rpc.py b/lib/rpc.py index f2c85db11ed1aa926d98d1bd74af04a387525c96..1304c12f01a44f7e5ad635242df63b5bb12b10be 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -362,25 +362,25 @@ def call_node_verify(node_list, checkdict): return c.getresult() -def call_node_start_master(node): +def call_node_start_master(node, start_daemons): """Tells a node to activate itself as a master. This is a single-node call. """ - c = Client("node_start_master", []) + c = Client("node_start_master", [start_daemons]) c.connect(node) c.run() return c.getresult().get(node, False) -def call_node_stop_master(node): +def call_node_stop_master(node, stop_daemons): """Tells a node to demote itself from master status. This is a single-node call. """ - c = Client("node_stop_master", []) + c = Client("node_stop_master", [stop_daemons]) c.connect(node) c.run() return c.getresult().get(node, False) @@ -803,4 +803,3 @@ def call_file_storage_dir_rename(node, old_file_storage_dir, c.connect(node) c.run() return c.getresult().get(node, False) -