From 2d88fdd36f87c6c08744190483914d6e6db1ccdb Mon Sep 17 00:00:00 2001 From: Andrea Spadaccini <spadaccio@google.com> Date: Tue, 25 Oct 2011 16:17:37 +0100 Subject: [PATCH] Add master IP turnup and turndown hooks Signed-off-by: Andrea Spadaccini <spadaccio@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 17 +++++++++++++++++ lib/constants.py | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/lib/backend.py b/lib/backend.py index 6c52d20d3..6d218e389 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -283,6 +283,21 @@ def RunLocalHooks(hook_opcode, hooks_path, env_builder_fn): 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(): """Activate the IP address of the master daemon. @@ -353,6 +368,8 @@ def StartMasterDaemons(no_voting): _Fail(msg) +@RunLocalHooks(constants.FAKE_OP_MASTER_TURNDOWN, "master-ip-turndown", + _BuildMasterIpHookEnv) def DeactivateMasterIp(): """Deactivate the master IP on this node. diff --git a/lib/constants.py b/lib/constants.py index 18c3f4d03..0b0ad4faf 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -1708,5 +1708,10 @@ HTOOLS = _autoconf.HTOOLS # The hail iallocator 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 del re, _vcsversion, _autoconf -- GitLab