Revision 237a833c lib/hooksmaster.py

b/lib/hooksmaster.py
46 46

  
47 47
class HooksMaster(object):
48 48
  def __init__(self, opcode, hooks_path, nodes, hooks_execution_fn,
49
               hooks_results_adapt_fn, build_env_fn, log_fn, htype=None,
50
               cluster_name=None, master_name=None):
49
               hooks_results_adapt_fn, build_env_fn, prepare_post_nodes_fn,
50
               log_fn, htype=None, cluster_name=None, master_name=None):
51 51
    """Base class for hooks masters.
52 52

  
53 53
    This class invokes the execution of hooks according to the behaviour
......
70 70
    @type build_env_fn: function that returns a dictionary having strings as
71 71
      keys
72 72
    @param build_env_fn: function that builds the environment for the hooks
73
    @type prepare_post_nodes_fn: function that take a list of node UUIDs and
74
      returns a list of node UUIDs
75
    @param prepare_post_nodes_fn: function that is invoked right before
76
      executing post hooks and can change the list of node UUIDs to run the post
77
      hooks on
73 78
    @type log_fn: function that accepts a string
74 79
    @param log_fn: logging function
75 80
    @type htype: string or None
......
86 91
    self.hooks_execution_fn = hooks_execution_fn
87 92
    self.hooks_results_adapt_fn = hooks_results_adapt_fn
88 93
    self.build_env_fn = build_env_fn
94
    self.prepare_post_nodes_fn = prepare_post_nodes_fn
89 95
    self.log_fn = log_fn
90 96
    self.htype = htype
91 97
    self.cluster_name = cluster_name
......
195 201
    elif phase == constants.HOOKS_PHASE_POST:
196 202
      if node_names is None:
197 203
        node_names = self.post_nodes
204
        if node_names is not None and self.prepare_post_nodes_fn is not None:
205
          node_names = frozenset(self.prepare_post_nodes_fn(list(node_names)))
198 206
      env = self._BuildEnv(phase)
199 207
    else:
200 208
      raise AssertionError("Unknown phase '%s'" % phase)
......
277 285

  
278 286
    return HooksMaster(lu.op.OP_ID, lu.HPATH, nodes, hooks_execution_fn,
279 287
                       _RpcResultsToHooksResults, lu.BuildHooksEnv,
280
                       lu.LogWarning, lu.HTYPE, cluster_name, master_name)
288
                       lu.PreparePostHookNodes, lu.LogWarning, lu.HTYPE,
289
                       cluster_name, master_name)

Also available in: Unified diff