Commit 3a3e4f1e authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Add netmask and IP version to master IP hooks env



Add the master netmask and master IP version parameters to the hooks and
document them. In this way, the hook environment building function can
be reused for the planned master IP turnup changes.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 41e079ce
......@@ -478,7 +478,7 @@ Modifies the cluster parameters.
Called when the master IP is activated.
:directory: master-ip-turnup
:env. vars: MASTER_NETDEV, MASTER_IP
:env. vars: MASTER_NETDEV, MASTER_IP, MASTER_NETMASK, CLUSTER_IP_VERSION
:pre-execution: master node
:post-execution: master node
......@@ -488,7 +488,7 @@ Called when the master IP is activated.
Called when the master IP is deactivated.
:directory: master-ip-turndown
:env. vars: MASTER_NETDEV, MASTER_IP
:env. vars: MASTER_NETDEV, MASTER_IP, MASTER_NETMASK, CLUSTER_IP_VERSION
:pre-execution: master node
:post-execution: master node
......@@ -549,6 +549,9 @@ Specialised variables
This is the list of variables which are specific to one or more
operations.
CLUSTER_IP_VERSION
IP version of the master IP (4 or 6)
INSTANCE_NAME
The name of the instance which is the target of the operation.
......@@ -627,6 +630,9 @@ MASTER_NETDEV
MASTER_IP
The master IP
MASTER_NETMASK
Netmask of the master IP
INSTANCE_TAGS
A space-delimited list of the instance's tags.
......
......@@ -283,21 +283,24 @@ def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
return decorator
def _BuildMasterIpHookEnv():
def _BuildMasterIpEnv():
"""Builds environment variables for master IP hooks.
"""
cfg = _GetConfig()
master_netdev, master_ip, _, family, master_netmask = GetMasterInfo()
version = str(netutils.IPAddress.GetVersionFromAddressFamily(family))
env = {
"MASTER_NETDEV": cfg.GetMasterNetdev(),
"MASTER_IP": cfg.GetMasterIP(),
"MASTER_NETDEV": master_netdev,
"MASTER_IP": master_ip,
"MASTER_NETMASK": master_netmask,
"CLUSTER_IP_VERSION": version,
}
return env
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
_BuildMasterIpHookEnv)
_BuildMasterIpEnv)
def ActivateMasterIp(master_ip, master_netmask, master_netdev, family):
"""Activate the IP address of the master daemon.
......@@ -374,7 +377,7 @@ def StartMasterDaemons(no_voting):
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown",
_BuildMasterIpHookEnv)
_BuildMasterIpEnv)
def DeactivateMasterIp(master_ip, master_netmask, master_netdev):
"""Deactivate the master IP on this node.
......
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