From 40167d65b0b2cf7c4ba1052acbbf6aae7bc24673 Mon Sep 17 00:00:00 2001
From: Adeodato Simo <dato@google.com>
Date: Tue, 3 May 2011 15:22:18 +0100
Subject: [PATCH] Cluster verify: accept a --node-group option

This will trigger a ClusterVerifyGroup operation only on the specified
group, skipping other groups as well as cluster-wide verifications.

Signed-off-by: Adeodato Simo <dato@google.com>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/client/gnt_cluster.py | 16 ++++++++++------
 man/gnt-cluster.rst       |  7 ++++++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index c5eebf775..dec37dc1b 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -456,12 +456,16 @@ def VerifyCluster(opts, args):
   simulate = opts.simulate_errors
   skip_checks = []
 
-  # Verify cluster config.
-  op = opcodes.OpClusterVerifyConfig(verbose=opts.verbose,
-                                     error_codes=opts.error_codes,
-                                     debug_simulate_errors=simulate)
+  if opts.nodegroup is None:
+    # Verify cluster config.
+    op = opcodes.OpClusterVerifyConfig(verbose=opts.verbose,
+                                       error_codes=opts.error_codes,
+                                       debug_simulate_errors=simulate)
 
-  success, all_groups = SubmitOpCode(op, opts=opts)
+    success, all_groups = SubmitOpCode(op, opts=opts)
+  else:
+    success = True
+    all_groups = [opts.nodegroup]
 
   if opts.skip_nplusone_mem:
     skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
@@ -1259,7 +1263,7 @@ commands = {
   'verify': (
     VerifyCluster, ARGS_NONE,
     [VERBOSE_OPT, DEBUG_SIMERR_OPT, ERROR_CODES_OPT, NONPLUS1_OPT,
-     DRY_RUN_OPT, PRIORITY_OPT],
+     DRY_RUN_OPT, PRIORITY_OPT, NODEGROUP_OPT],
     "", "Does a check on the cluster configuration"),
   'verify-disks': (
     VerifyDisks, ARGS_NONE, [PRIORITY_OPT],
diff --git a/man/gnt-cluster.rst b/man/gnt-cluster.rst
index 866fba64c..d3fcecd15 100644
--- a/man/gnt-cluster.rst
+++ b/man/gnt-cluster.rst
@@ -579,7 +579,7 @@ node will be listed as /nodes/*name*, and an instance as
 VERIFY
 ~~~~~~
 
-**verify** [--no-nplus1-mem]
+**verify** [--no-nplus1-mem] [--node-group *nodegroup*]
 
 Verify correctness of cluster configuration. This is safe with
 respect to running instances, and incurs no downtime of the
@@ -589,6 +589,11 @@ If the ``--no-nplus1-mem`` option is given, Ganeti won't check
 whether if it loses a node it can restart all the instances on
 their secondaries (and report an error otherwise).
 
+With ``--node-group``, restrict the verification to those nodes and
+instances that live in the named group. This will not verify global
+settings, but will allow to perform verification of a group while other
+operations are ongoing in other groups.
+
 VERIFY-DISKS
 ~~~~~~~~~~~~
 
-- 
GitLab