Commit 8da2bd43 authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Explicitly pass params to activate_master_ip



To remove the usage of ssconf in the backend, the master needs to push
the parameters of activate_master_ip to the backend.

This patch changes the entire call path of activate_master_ip to use the
new interface.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 5d7a899e
......@@ -298,9 +298,14 @@ def _BuildMasterIpHookEnv():
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
_BuildMasterIpHookEnv)
def ActivateMasterIp():
def ActivateMasterIp(master_ip, master_netmask, master_netdev, family):
"""Activate the IP address of the master daemon.
@param master_ip: the master IP
@param master_netmask: the master IP netmask
@param master_netdev: the master network device
@param family: the IP family
"""
# GetMasterInfo will raise an exception if not able to return data
master_netdev, master_ip, _, family, master_netmask = GetMasterInfo()
......
......@@ -3323,17 +3323,17 @@ class LUClusterRename(LogicalUnit):
"""
clustername = self.op.name
ip = self.ip
new_ip = self.ip
# shutdown the master IP
master = self.cfg.GetMasterNode()
(master, _, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
result = self.rpc.call_node_deactivate_master_ip(master)
result.Raise("Could not disable the master role")
try:
cluster = self.cfg.GetClusterInfo()
cluster.cluster_name = clustername
cluster.master_ip = ip
cluster.master_ip = new_ip
self.cfg.Update(cluster, feedback_fn)
# update the known hosts file
......@@ -3345,7 +3345,8 @@ class LUClusterRename(LogicalUnit):
pass
_UploadHelper(self, node_list, constants.SSH_KNOWN_HOSTS_FILE)
finally:
result = self.rpc.call_node_activate_master_ip(master)
result = self.rpc.call_node_activate_master_ip(master, new_ip, netmask,
dev, family)
msg = result.fail_msg
if msg:
self.LogWarning("Could not re-enable the master role on"
......@@ -3723,9 +3724,11 @@ class LUClusterSetParams(LogicalUnit):
self.cfg.Update(self.cluster, feedback_fn)
if self.op.master_netdev:
(master, ip, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
feedback_fn("Starting the master ip on the new master netdev (%s)" %
self.op.master_netdev)
result = self.rpc.call_node_activate_master_ip(master)
result = self.rpc.call_node_activate_master_ip(master, ip, netmask, dev,
family)
if result.fail_msg:
self.LogWarning("Could not re-enable the master ip on"
" the master, please restart manually: %s",
......@@ -3887,8 +3890,8 @@ class LUClusterActivateMasterIp(NoHooksLU):
"""Activate the master IP.
"""
master = self.cfg.GetMasterNode()
self.rpc.call_node_activate_master_ip(master)
(master, ip, dev, netmask, family) = self.cfg.GetMasterNetworkParameters()
self.rpc.call_node_activate_master_ip(master, ip, netmask, dev, family)
class LUClusterDeactivateMasterIp(NoHooksLU):
......
......@@ -398,8 +398,13 @@ CALLS = {
("node_start_master_daemons", SINGLE, TMO_FAST, [
("no_voting", None, None),
], None, "Starts master daemons on a node"),
("node_activate_master_ip", SINGLE, TMO_FAST, [], None,
"Activates master IP on a node"),
("node_activate_master_ip", SINGLE, TMO_FAST, [
("master_ip", None, "The master IP"),
("master_netmask", None, "The master IP netmask"),
("master_netdev", None, "The master network device"),
("ip_family", None, "The cluster IP family"),
], None,
"Activates master IP on a node"),
("node_stop_master", SINGLE, TMO_FAST, [], None,
"Deactivates master IP and stops master daemons on a node"),
("node_deactivate_master_ip", SINGLE, TMO_FAST, [], None,
......
......@@ -533,8 +533,11 @@ def CheckAgreement():
@rpc.RunWithRPC
def ActivateMasterIP():
# activate ip
master_node = ssconf.SimpleStore().GetMasterNode()
result = rpc.BootstrapRunner().call_node_activate_master_ip(master_node)
cfg = config.ConfigWriter()
(master, ip, dev, netmask, family) = cfg.GetMasterNetworkParameters()
runner = rpc.BootstrapRunner()
result = runner.call_node_activate_master_ip(master, ip, netmask, dev, family)
msg = result.fail_msg
if msg:
logging.error("Can't activate master IP address: %s", msg)
......
......@@ -697,7 +697,7 @@ class NodeHttpServer(http.server.HttpServer):
"""Activate the master IP on this node.
"""
return backend.ActivateMasterIp()
return backend.ActivateMasterIp(params[0], params[1], params[2], params[3])
@staticmethod
def perspective_node_deactivate_master_ip(params):
......
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