"""
raise NotImplementedError
+ def HooksCallBack(self, phase, hook_results, feedback_fn, lu_result):
+ """Notify the LU about the results of its hooks.
+
+ This method is called every time a hooks phase is executed, and notifies
+ the Logical Unit about the hooks' result. The LU can then use it to alter
+ its result based on the hooks. By default the method does nothing and the
+ previous result is passed back unchanged but any LU can define it if it
+ wants to use the local cluster hook-scripts somehow.
+
+ Args:
+ phase: the hooks phase that has just been run
+ hooks_results: the results of the multi-node hooks rpc call
+ feedback_fn: function to send feedback back to the caller
+ lu_result: the previous result this LU had, or None in the PRE phase.
+
+ """
+ return lu_result
+
class NoHooksLU(LogicalUnit):
"""Simple LU which runs no hooks.
lu = lu_class(self, op, self.cfg, self.sstore)
lu.CheckPrereq()
hm = HooksMaster(rpc.call_hooks_runner, self, lu)
- hm.RunPhase(constants.HOOKS_PHASE_PRE)
+ h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
+ lu.HooksCallBack(constants.HOOKS_PHASE_PRE,
+ h_results, self._feedback_fn, None)
try:
result = lu.Exec(self._feedback_fn)
- hm.RunPhase(constants.HOOKS_PHASE_POST)
+ h_results = hm.RunPhase(constants.HOOKS_PHASE_POST)
+ result = lu.HooksCallBack(constants.HOOKS_PHASE_POST,
+ h_results, self._feedback_fn, result)
finally:
if lu.cfg is not None:
# we use lu.cfg and not self.cfg as for init cluster, self.cfg
lu.CheckPrereq()
#if do_hooks:
# hm = HooksMaster(rpc.call_hooks_runner, self, lu)
- # hm.RunPhase(constants.HOOKS_PHASE_PRE)
+ # h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
+ # lu.HooksCallBack(constants.HOOKS_PHASE_PRE,
+ # h_results, self._feedback_fn, None)
result = lu.Exec(self._feedback_fn)
#if do_hooks:
- # hm.RunPhase(constants.HOOKS_PHASE_POST)
+ # h_results = hm.RunPhase(constants.HOOKS_PHASE_POST)
+ # result = lu.HooksCallBack(constants.HOOKS_PHASE_POST,
+ # h_results, self._feedback_fn, result)
return result
def LogStep(self, current, total, message):