From 4f365444adf64a2b96f993f11a7a395d26de0c7e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 10:57:46 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--disk-template=E2=80=9D?=
 =?UTF-8?q?=20option?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cli.py           | 7 +++++++
 scripts/gnt-backup   | 5 +----
 scripts/gnt-debug    | 4 +---
 scripts/gnt-instance | 5 +----
 4 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index bbe5158b3..3b1156c7a 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -47,6 +47,7 @@ __all__ = [
   "CONFIRM_OPT",
   "DEBUG_OPT",
   "DEBUG_SIMERR_OPT",
+  "DISK_TEMPLATE_OPT",
   "FIELDS_OPT",
   "FORCE_OPT",
   "NOHDR_OPT",
@@ -475,6 +476,12 @@ NWSYNC_OPT = cli_option("--no-wait-for-sync", dest="wait_for_sync",
                         default=True, action="store_false",
                         help="Don't wait for sync (DANGEROUS!)")
 
+DISK_TEMPLATE_OPT = cli_option("-t", "--disk-template", dest="disk_template",
+                               help="Custom disk setup (diskless, file,"
+                               " plain or drbd)",
+                               default=None, metavar="TEMPL",
+                               choices=list(constants.DISK_TEMPLATES))
+
 
 def _ParseArgs(argv, commands, aliases):
   """Parser for the command line arguments.
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index a45256f74..8ee9b6745 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -218,10 +218,7 @@ import_opts = [
   cli_option("-B", "--backend", dest="beparams",
              type="keyval", default={},
              help="Backend parameters"),
-  cli_option("-t", "--disk-template", dest="disk_template",
-             help="Custom disk setup (diskless, file, plain, drbd)",
-             default=None, metavar="TEMPL",
-             choices=list(constants.DISK_TEMPLATES)),
+  DISK_TEMPLATE_OPT,
   cli_option("--disk", help="Disk information",
              default=[], dest="disks",
              action="append",
diff --git a/scripts/gnt-debug b/scripts/gnt-debug
index b582c5e58..80ea6c188 100755
--- a/scripts/gnt-debug
+++ b/scripts/gnt-debug
@@ -198,9 +198,7 @@ commands = {
                             help="Memory size for the instance (MiB)"),
                  cli_option("--disks", default="4096,4096",
                             help="Comma separated list of disk sizes (MiB)"),
-                 cli_option("-t", "--disk-template", default="drbd",
-                            help="Select the disk template",
-                            choices=list(constants.DISK_TEMPLATES)),
+                 DISK_TEMPLATE_OPT,
                  cli_option("--nics", default="00:11:22:33:44:55",
                             help="Comma separated list of nics, each nic"
                             " definition is of form mac/ip/bridge, if"
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 256b39a4c..05b2a45a7 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -1375,10 +1375,7 @@ add_opts = [
   cli_option("-B", "--backend", dest="beparams",
              type="keyval", default={},
              help="Backend parameters"),
-  cli_option("-t", "--disk-template", dest="disk_template",
-             help="Custom disk setup (diskless, file, plain or drbd)",
-             default=None, metavar="TEMPL",
-             choices=list(constants.DISK_TEMPLATES)),
+  DISK_TEMPLATE_OPT,
   cli_option("-s", "--os-size", dest="sd_size", help="Disk size for a"
              " single-disk configuration, when not using the --disk option,"
              " in MiB unless a suffix is used",
-- 
GitLab