Add --ignore-errors parameter to cluster verify
authorAndrea Spadaccini <spadaccio@google.com>
Tue, 4 Oct 2011 12:26:43 +0000 (13:26 +0100)
committerAndrea Spadaccini <spadaccio@google.com>
Wed, 5 Oct 2011 12:17:23 +0000 (13:17 +0100)
lib/cli.py
- add IGNORE_ERROR_OPT;

client/gnt_cluster.py
- pass the ignore_errors parameter to the opcodes

lib/opcode.py
- update OpClusterVerifyConfig, OpClusterVerify and OpClusterVerifyGroup
  to accept the ignore_errors parameter

lib/cmdlib.py
- pass the ignore_errors parameter to the opcodes that need it

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cli.py
lib/client/gnt_cluster.py
lib/cmdlib.py
lib/opcodes.py

index 0e01980..9622a5b 100644 (file)
@@ -92,6 +92,7 @@ __all__ = [
   "DEFAULT_IALLOCATOR_OPT",
   "IDENTIFY_DEFAULTS_OPT",
   "IGNORE_CONSIST_OPT",
+  "IGNORE_ERRORS_OPT",
   "IGNORE_FAILURES_OPT",
   "IGNORE_OFFLINE_OPT",
   "IGNORE_REMOVE_FAILURES_OPT",
@@ -1262,6 +1263,11 @@ TO_GROUP_OPT = cli_option("--to", dest="to", metavar="<group>",
                           default=None, action="append",
                           completion_suggest=OPT_COMPL_ONE_NODEGROUP)
 
+IGNORE_ERRORS_OPT = cli_option("-I", "--ignore-errors", default=[],
+                               action="append", dest="ignore_errors",
+                               choices=list(constants.CV_ALL_ECODES_STRINGS),
+                               help="Error code to be ignored")
+
 
 #: Options provided by all commands
 COMMON_OPTS = [DEBUG_OPT]
index cd0f719..26d3c3f 100644 (file)
@@ -502,6 +502,7 @@ def VerifyCluster(opts, args):
                                error_codes=opts.error_codes,
                                debug_simulate_errors=opts.simulate_errors,
                                skip_checks=skip_checks,
+                               ignore_errors=opts.ignore_errors,
                                group_name=opts.nodegroup)
   result = SubmitOpCode(op, cl=cl, opts=opts)
 
@@ -1380,7 +1381,7 @@ commands = {
   "verify": (
     VerifyCluster, ARGS_NONE,
     [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT,
-     DRY_RUN_OPT, PRIORITY_OPT, NODEGROUP_OPT],
+     DRY_RUN_OPT, PRIORITY_OPT, NODEGROUP_OPT, IGNORE_ERRORS_OPT],
     "", "Does a check on the cluster configuration"),
   "verify-disks": (
     VerifyDisks, ARGS_NONE, [PRIORITY_OPT],
index b539a3c..25cd316 100644 (file)
@@ -1496,13 +1496,16 @@ class LUClusterVerify(NoHooksLU):
       groups = self.cfg.GetNodeGroupList()
 
       # Verify global configuration
-      jobs.append([opcodes.OpClusterVerifyConfig()])
+      jobs.append([
+        opcodes.OpClusterVerifyConfig(ignore_errors=self.op.ignore_errors)
+        ])
 
       # Always depend on global verification
       depends_fn = lambda: [(-len(jobs), [])]
 
     jobs.extend([opcodes.OpClusterVerifyGroup(group_name=group,
-                                              depends=depends_fn())]
+                                            ignore_errors=self.op.ignore_errors,
+                                            depends=depends_fn())]
                 for group in groups)
 
     # Fix up all parameters
index 124fde0..3e159e1 100644 (file)
@@ -137,6 +137,9 @@ _PErrorCodes = ("error_codes", False, ht.TBool, "Error codes")
 _PSkipChecks = ("skip_checks", ht.EmptyList,
                 ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS)),
                 "Which checks to skip")
+_PIgnoreErrors = ("ignore_errors", ht.EmptyList,
+                  ht.TListOf(ht.TElemOf(constants.CV_ALL_ECODES_STRINGS)),
+                  "List of error codes that should be treated as warnings")
 
 #: OP_ID conversion regular expression
 _OPID_RE = re.compile("([a-z])([A-Z])")
@@ -613,6 +616,7 @@ class OpClusterVerify(OpCode):
     _PDebugSimulateErrors,
     _PErrorCodes,
     _PSkipChecks,
+    _PIgnoreErrors,
     _PVerbose,
     ("group_name", None, ht.TMaybeString, "Group to verify")
     ]
@@ -626,6 +630,7 @@ class OpClusterVerifyConfig(OpCode):
   OP_PARAMS = [
     _PDebugSimulateErrors,
     _PErrorCodes,
+    _PIgnoreErrors,
     _PVerbose,
     ]
   OP_RESULT = ht.TBool
@@ -647,6 +652,7 @@ class OpClusterVerifyGroup(OpCode):
     _PDebugSimulateErrors,
     _PErrorCodes,
     _PSkipChecks,
+    _PIgnoreErrors,
     _PVerbose,
     ]
   OP_RESULT = ht.TBool