def RunPhase(self, phase, node_uuids=None, is_global=False,
               post_status=None):
    if phase == constants.HOOKS_PHASE_PRE:
      if node_uuids is None:
        node_uuids = self.pre_nodes
      env = self.pre_env
    elif phase == constants.HOOKS_PHASE_POST:
      if node_uuids is None:
        node_uuids = self.post_nodes
        if node_uuids is not None and self.prepare_post_nodes_fn is not None:
          node_uuids = frozenset(self.prepare_post_nodes_fn(list(node_uuids)))
      env = self._BuildEnv(phase)
    else:
      raise AssertionError("Unknown phase '%s'" % phase)

    if not node_uuids and not is_global:
      # empty node list, we should not attempt to run this as either
      # we're in the cluster init phase and the rpc client part can't
      # even attempt to run, or this LU doesn't do hooks at all
      return

    hooks_path = constants.GLOBAL_HOOKS_DIR if is_global else self.hooks_path
    results = self._RunWrapper(node_uuids, hooks_path, phase, env, is_global,
                               post_status)
    if not results:
      msg = "Communication Failure"
      if phase == constants.HOOKS_PHASE_PRE:
        raise errors.HooksFailure(msg)
      else:
        self.log_fn(msg)
        return results

    converted_res = results
    if self.hooks_results_adapt_fn:
      converted_res = self.hooks_results_adapt_fn(results)

    errs = []
    for node_name, (fail_msg, offline, hooks_results) in converted_res.items():
      if offline:
        continue

      if fail_msg:
        self.log_fn("Communication failure to node %s: %s", node_name, fail_msg)
        continue

      for script, hkr, output in hooks_results:
        if hkr == constants.HKR_FAIL:
          if phase == constants.HOOKS_PHASE_PRE:
            errs.append((node_name, script, output))
          else:
            if not output:
              output = "(no output)"
            self.log_fn("On %s script %s failed, output: %s" %
                        (node_name, script, output))

    if errs and phase == constants.HOOKS_PHASE_PRE:
      raise errors.HooksAbort(errs)

    return results
Search for stack.yaml in parent directories
dataset/ETHPy150Open ganeti/ganeti/lib/hooksmaster.py/HooksMaster.RunPhase--crossover with--dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/sublime_haskell_common.py/is_stack_project