Commit 2d88fdd3 authored by Andrea Spadaccini's avatar Andrea Spadaccini
Browse files

Add master IP turnup and turndown hooks


Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 0fa481f5
...@@ -283,6 +283,21 @@ def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn): ...@@ -283,6 +283,21 @@ def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn):
return decorator return decorator
def _BuildMasterIpHookEnv():
"""Builds environment variables for master IP hooks.
"""
cfg = _GetConfig()
env = {
"MASTER_NETDEV": cfg.GetMasterNetdev(),
"MASTER_IP": cfg.GetMasterIP(),
}
return env
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNUP, "master-ip-turnup",
_BuildMasterIpHookEnv)
def ActivateMasterIp(): def ActivateMasterIp():
"""Activate the IP address of the master daemon. """Activate the IP address of the master daemon.
...@@ -353,6 +368,8 @@ def StartMasterDaemons(no_voting): ...@@ -353,6 +368,8 @@ def StartMasterDaemons(no_voting):
_Fail(msg) _Fail(msg)
@RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown",
_BuildMasterIpHookEnv)
def DeactivateMasterIp(): def DeactivateMasterIp():
"""Deactivate the master IP on this node. """Deactivate the master IP on this node.
......
...@@ -1708,5 +1708,10 @@ HTOOLS = _autoconf.HTOOLS ...@@ -1708,5 +1708,10 @@ HTOOLS = _autoconf.HTOOLS
# The hail iallocator # The hail iallocator
IALLOC_HAIL = "hail" IALLOC_HAIL = "hail"
# Fake opcodes for functions that have hooks attached to them via
# backend.RunLocalHooks
FAKE_OP_MASTER_TURNUP = "OP_CLUSTER_IP_TURNUP"
FAKE_OP_MASTER_TURNDOWN = "OP_CLUSTER_IP_TURNDOWN"
# Do not re-export imported modules # Do not re-export imported modules
del re, _vcsversion, _autoconf del re, _vcsversion, _autoconf
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