Commit 6a4aa7c1 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement post-configuration-update hook

This patch adds a special hook: the post-configuration update hook. This
hook has only a post phase that runs after a top-level LU that modified
the configuration.

Since the hook is a post-phase one, no error checking is done on the
results. The hook runs only on the master.

Reviewed-by: imsnah
parent 4167825b
......@@ -62,6 +62,7 @@ XEN_INITRD = _autoconf.XEN_INITRD
HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks"
HOOKS_NAME_CFGUPDATE = "config-update"
# hooks subject type (what object type does the LU deal with)
......@@ -112,12 +112,23 @@ class Processor(object):
if lu_class.REQ_CLUSTER and self.cfg is None:
self.cfg = config.ConfigWriter()
self.sstore = ssconf.SimpleStore()
if self.cfg is not None:
write_count = self.cfg.write_count
write_count = 0
lu = lu_class(self, op, self.cfg, self.sstore)
hm = HooksMaster(rpc.call_hooks_runner, lu)
result = lu.Exec(feedback_fn)
if lu.cfg is not None:
# we use lu.cfg and not self.cfg as for init cluster, self.cfg
# is None but lu.cfg has been recently initialized in the
# lu.Exec method
if write_count != lu.cfg.write_count:
return result
def ChainOpCode(self, op, feedback_fn):
......@@ -186,6 +197,7 @@ class HooksMaster(object):
"GANETI_OP_CODE": self.op.OP_ID,
if is not None:
......@@ -243,3 +255,17 @@ class HooksMaster(object):
errs.append((node_name, script, output))
if errs:
raise errors.HooksAbort(errs)
def RunConfigUpdate(self):
"""Run the special configuration update hook
This is a special hook that runs only on the master after each
top-level LI if the configuration has been updated.
phase = constants.HOOKS_PHASE_POST
hpath = constants.HOOKS_NAME_CFGUPDATE
if is None:
raise errors.ProgrammerError("Null sstore on config update hook")
nodes = []
results = self._RunWrapper(nodes, hpath, phase)
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