Verify: make skipping checks possible
authorGuido Trotter <ultrotter@google.com>
Thu, 10 Apr 2008 17:04:13 +0000 (17:04 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 10 Apr 2008 17:04:13 +0000 (17:04 +0000)
Add a general way to skip some checks at cluster-verify time and make the N+1
memory redundancy check optional.

Reviewed-by: iustinp

lib/cmdlib.py
lib/constants.py
lib/opcodes.py
scripts/gnt-cluster

index 6bb48f8..45a0bfb 100644 (file)
@@ -603,7 +603,7 @@ class LUVerifyCluster(NoHooksLU):
   """Verifies the cluster status.
 
   """
-  _OP_REQP = []
+  _OP_REQP = ["skip_checks"]
 
   def _VerifyNode(self, node, file_list, local_cksum, vglist, node_result,
                   remote_version, feedback_fn):
@@ -776,10 +776,13 @@ class LUVerifyCluster(NoHooksLU):
   def CheckPrereq(self):
     """Check prerequisites.
 
-    This has no prerequisites.
+    Transform the list of checks we're going to skip into a set and check that
+    all its members are valid.
 
     """
-    pass
+    self.skip_set = frozenset(self.op.skip_checks)
+    if not constants.VERIFY_OPTIONAL_CHECKS.issuperset(self.skip_set):
+      raise errors.OpPrereqError("Invalid checks to be skipped specified")
 
   def Exec(self, feedback_fn):
     """Verify integrity of cluster, performing various test on nodes.
@@ -928,9 +931,10 @@ class LUVerifyCluster(NoHooksLU):
                                          feedback_fn)
     bad = bad or result
 
-    feedback_fn("* Verifying N+1 Memory redundancy")
-    result = self._VerifyNPlusOneMemory(node_info, instance_cfg, feedback_fn)
-    bad = bad or result
+    if constants.VERIFY_NPLUSONE_MEM not in self.skip_set:
+      feedback_fn("* Verifying N+1 Memory redundancy")
+      result = self._VerifyNPlusOneMemory(node_info, instance_cfg, feedback_fn)
+      bad = bad or result
 
     feedback_fn("* Other Notes")
     if i_non_redundant:
index 0487ab8..1879ffd 100644 (file)
@@ -179,3 +179,8 @@ HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
 HT_HVM_VNC_BASE_PORT = 5900
 HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
 VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
+
+# Cluster Verify steps
+VERIFY_NPLUSONE_MEM = 'nplusone_mem'
+VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
+
index 3d7a3b0..7e2f780 100644 (file)
@@ -194,7 +194,7 @@ class OpRunClusterCommand(OpCode):
 class OpVerifyCluster(OpCode):
   """Verify the cluster state."""
   OP_ID = "OP_CLUSTER_VERIFY"
-  __slots__ = []
+  __slots__ = ["skip_checks"]
 
 
 class OpVerifyDisks(OpCode):
index fdaea3f..f5514ff 100755 (executable)
@@ -187,7 +187,10 @@ def VerifyCluster(opts, args):
     opts - class with options as members
 
   """
-  op = opcodes.OpVerifyCluster()
+  skip_checks=[]
+  if opts.skip_nplusone_mem:
+    skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
+  op = opcodes.OpVerifyCluster(skip_checks=skip_checks)
   result = SubmitOpCode(op)
   return result
 
@@ -368,7 +371,12 @@ commands = {
   'rename': (RenameCluster, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
                "<new_name>",
                "Renames the cluster"),
-  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT],
+  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
+             make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
+                         help="Skip N+1 memory redundancy tests",
+                         action="store_true",
+                         default=False,),
+             ],
              "", "Does a check on the cluster configuration"),
   'verify-disks': (VerifyDisks, ARGS_NONE, [DEBUG_OPT],
                    "", "Does a check on the cluster disk status"),