From 383a3591671269b1950eb368a22197c7d04fefab Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 14:13:41 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--enabled-hypervisors?=
 =?UTF-8?q?=E2=80=9D=20option?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This also required a change, as one of the cases used a different
default.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cli.py          |  6 ++++++
 scripts/gnt-cluster | 11 ++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 717d99efe..bcf8d8b82 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -56,6 +56,7 @@ __all__ = [
   "DISK_OPT",
   "DISK_TEMPLATE_OPT",
   "DRAINED_OPT",
+  "ENABLED_HV_OPT",
   "FIELDS_OPT",
   "FILESTORE_DIR_OPT",
   "FILESTORE_DRIVER_OPT",
@@ -721,6 +722,11 @@ NOLVM_STORAGE_OPT = cli_option("--no-lvm-storage", dest="lvm_storage",
                                " (cluster-wide)",
                                action="store_false", default=True)
 
+ENABLED_HV_OPT = cli_option("--enabled-hypervisors",
+                            dest="enabled_hypervisors",
+                            help="Comma-separated list of hypervisors",
+                            type="string", default=None)
+
 
 def _ParseArgs(argv, commands, aliases):
   """Parser for the command line arguments.
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index b2ec12bd1..173f3ded2 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -58,6 +58,8 @@ def InitCluster(opts, args):
     vg_name = constants.DEFAULT_VG
 
   hvlist = opts.enabled_hypervisors
+  if hvlist is None:
+    hvlist = constants.DEFAULT_ENABLED_HYPERVISOR
   hvlist = hvlist.split(",")
 
   hvparams = dict(opts.hvparams)
@@ -617,10 +619,7 @@ commands = {
                        help="Don't modify /etc/hosts"
                             " (cluster-wide)",
                        action="store_false", default=True,),
-            cli_option("--enabled-hypervisors", dest="enabled_hypervisors",
-                       help="Comma-separated list of hypervisors",
-                       type="string",
-                       default=constants.DEFAULT_ENABLED_HYPERVISOR),
+            ENABLED_HV_OPT,
             HVLIST_OPT,
             BACKEND_OPT,
             cli_option("-N", "--nic-parameters", dest="nicparams",
@@ -710,9 +709,7 @@ commands = {
                          "and enable lvm based storage",
                          metavar="VG",),
               NOLVM_STORAGE_OPT,
-              cli_option("--enabled-hypervisors", dest="enabled_hypervisors",
-                         help="Comma-separated list of hypervisors",
-                         type="string", default=None),
+              ENABLED_HV_OPT,
               HVLIST_OPT,
               BACKEND_OPT,
               cli_option("-N", "--nic-parameters", dest="nicparams",
-- 
GitLab