Revision d8fff41c lib/cmdlib.py

b/lib/cmdlib.py
606 606
    rpc.call_node_leave_cluster(master)
607 607

  
608 608

  
609
class LUVerifyCluster(NoHooksLU):
609
class LUVerifyCluster(LogicalUnit):
610 610
  """Verifies the cluster status.
611 611

  
612 612
  """
613
  HPATH = "cluster-verify"
614
  HTYPE = constants.HTYPE_CLUSTER
613 615
  _OP_REQP = ["skip_checks"]
614 616

  
615 617
  def _VerifyNode(self, node, file_list, local_cksum, vglist, node_result,
......
791 793
    if not constants.VERIFY_OPTIONAL_CHECKS.issuperset(self.skip_set):
792 794
      raise errors.OpPrereqError("Invalid checks to be skipped specified")
793 795

  
796
  def BuildHooksEnv(self):
797
    """Build hooks env.
798

  
799
    Cluster-Verify hooks just rone in the post phase and their failure makes
800
    the output be logged in the verify output and the verification to fail.
801

  
802
    """
803
    all_nodes = self.cfg.GetNodeList()
804
    # TODO: populate the environment with useful information for verify hooks
805
    env = {}
806
    return env, [], all_nodes
807

  
794 808
  def Exec(self, feedback_fn):
795 809
    """Verify integrity of cluster, performing various test on nodes.
796 810

  
......
950 964

  
951 965
    return int(bad)
952 966

  
967
  def HooksCallBack(self, phase, hooks_results, feedback_fn, lu_result):
968
    """Analize the post-hooks' result, handle it, and send some
969
    nicely-formatted feedback back to the user.
970

  
971
    Args:
972
      phase: the hooks phase that has just been run
973
      hooks_results: the results of the multi-node hooks rpc call
974
      feedback_fn: function to send feedback back to the caller
975
      lu_result: previous Exec result
976

  
977
    """
978
    # We only really run POST phase hooks, and are only interested in their results
979
    if phase == constants.HOOKS_PHASE_POST:
980
      # Used to change hooks' output to proper indentation
981
      indent_re = re.compile('^', re.M)
982
      feedback_fn("* Hooks Results")
983
      if not hooks_results:
984
        feedback_fn("  - ERROR: general communication failure")
985
        lu_result = 1
986
      else:
987
        for node_name in hooks_results:
988
          show_node_header = True
989
          res = hooks_results[node_name]
990
          if res is False or not isinstance(res, list):
991
            feedback_fn("    Communication failure")
992
            lu_result = 1
993
            continue
994
          for script, hkr, output in res:
995
            if hkr == constants.HKR_FAIL:
996
              # The node header is only shown once, if there are
997
              # failing hooks on that node
998
              if show_node_header:
999
                feedback_fn("  Node %s:" % node_name)
1000
                show_node_header = False
1001
              feedback_fn("    ERROR: Script %s failed, output:" % script)
1002
              output = indent_re.sub('      ', output)
1003
              feedback_fn("%s" % output)
1004
              lu_result = 1
1005

  
1006
      return lu_result
1007

  
953 1008

  
954 1009
class LUVerifyDisks(NoHooksLU):
955 1010
  """Verifies the cluster disks status.

Also available in: Unified diff