Commit 1c65840b authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a new parameter to backend.(Start|Stop)Master

This patch adds a new, unused for now, parameter to the start and stop
master operations in backend. The idea behind it is that we need to be
able to control whether the IP (de)activation is coupled with daemon
startup/shutdown.

The callers are also modified to pass this parameter (even if unused for
now).

Reviewed-by: ultrotter
parent 6aff91f6
......@@ -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):
......
......@@ -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"])
......
......@@ -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,"
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment