Commit b5f5fae9 authored by Luca Bigliardi's avatar Luca Bigliardi
Browse files

Post cluster initialization LU



Add an 'empty' logical unit to run hooks after cluster initialization.
Signed-off-by: default avatarLuca Bigliardi <shammash@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4dfac6af
...@@ -749,6 +749,35 @@ def _GetStorageTypeArgs(cfg, storage_type): ...@@ -749,6 +749,35 @@ def _GetStorageTypeArgs(cfg, storage_type):
return [] return []
class LUPostInitCluster(LogicalUnit):
"""Logical unit for running hooks after cluster initialization.
"""
HPATH = "cluster-init"
HTYPE = constants.HTYPE_CLUSTER
_OP_REQP = []
def BuildHooksEnv(self):
"""Build hooks env.
"""
env = {"OP_TARGET": self.cfg.GetClusterName()}
mn = self.cfg.GetMasterNode()
return env, [], [mn]
def CheckPrereq(self):
"""No prerequisites to check.
"""
return True
def Exec(self, feedback_fn):
"""Nothing to do.
"""
return True
class LUDestroyCluster(NoHooksLU): class LUDestroyCluster(NoHooksLU):
"""Logical unit for destroying the cluster. """Logical unit for destroying the cluster.
......
...@@ -42,6 +42,7 @@ class Processor(object): ...@@ -42,6 +42,7 @@ class Processor(object):
"""Object which runs OpCodes""" """Object which runs OpCodes"""
DISPATCH_TABLE = { DISPATCH_TABLE = {
# Cluster # Cluster
opcodes.OpPostInitCluster: cmdlib.LUPostInitCluster,
opcodes.OpDestroyCluster: cmdlib.LUDestroyCluster, opcodes.OpDestroyCluster: cmdlib.LUDestroyCluster,
opcodes.OpQueryClusterInfo: cmdlib.LUQueryClusterInfo, opcodes.OpQueryClusterInfo: cmdlib.LUQueryClusterInfo,
opcodes.OpVerifyCluster: cmdlib.LUVerifyCluster, opcodes.OpVerifyCluster: cmdlib.LUVerifyCluster,
......
...@@ -170,6 +170,17 @@ class OpCode(BaseOpCode): ...@@ -170,6 +170,17 @@ class OpCode(BaseOpCode):
# cluster opcodes # cluster opcodes
class OpPostInitCluster(OpCode):
"""Post cluster initialization.
This opcode does not touch the cluster at all. Its purpose is to run hooks
after the cluster has been initialized.
"""
OP_ID = "OP_CLUSTER_POST_INIT"
__slots__ = OpCode.__slots__ + []
class OpDestroyCluster(OpCode): class OpDestroyCluster(OpCode):
"""Destroy the cluster. """Destroy the cluster.
......
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