diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6bb48f8c87bff688f35f430c1544a558a4c45b0d..45a0bfb9e4fe89c2557587cb420f683a47e1ca01 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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: diff --git a/lib/constants.py b/lib/constants.py index 0487ab817eb93ab3fb1f99a60f400c9f6966ae8b..1879ffd2e6016876ec92a96eeaf4cd889ca75a6c 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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]) + diff --git a/lib/opcodes.py b/lib/opcodes.py index 3d7a3b01e651ce4063ae279c5977288bccad565d..7e2f780c382084a3e572bd9bb48df5089cc313a3 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -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): diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index fdaea3fb87557176077026bf744ffe3a452173ab..f5514ff11f5b0ce051f944561b9a58f30cf2c792 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -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"),