From e3876ccb24772ea076bafe11a6322e4646fecc85 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 12:41:44 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--disk=E2=80=9D=20(ident?=
 =?UTF-8?q?keyval)=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: Michael Hanselmann <hansmi@google.com>
---
 lib/cli.py           |  4 ++++
 scripts/gnt-backup   |  5 +----
 scripts/gnt-instance | 17 +++--------------
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 7d69b7024..dd8f375d8 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -49,6 +49,7 @@ __all__ = [
   "DEBUG_OPT",
   "DEBUG_SIMERR_OPT",
   "DISK_TEMPLATE_OPT",
+  "DISK_OPT",
   "FIELDS_OPT",
   "FILESTORE_DIR_OPT",
   "FILESTORE_DRIVER_OPT",
@@ -544,6 +545,9 @@ NET_OPT = cli_option("--net",
                      help="NIC parameters", default=[],
                      dest="nics", action="append", type="identkeyval")
 
+DISK_OPT = cli_option("--disk", help="Disk parameters", default=[],
+                      dest="disks", action="append", type="identkeyval")
+
 
 def _ParseArgs(argv, commands, aliases):
   """Parser for the command line arguments.
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index cdcddac84..242de2ede 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -217,10 +217,7 @@ import_opts = [
              completion_suggest=OPT_COMPL_INST_ADD_NODES),
   BACKEND_OPT,
   DISK_TEMPLATE_OPT,
-  cli_option("--disk", help="Disk information",
-             default=[], dest="disks",
-             action="append",
-             type="identkeyval"),
+  DISK_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",
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index b042f0f25..cd1e651f4 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -1374,10 +1374,7 @@ add_opts = [
              " single-disk configuration, when not using the --disk option,"
              " in MiB unless a suffix is used",
              default=None, type="unit", metavar="<size>"),
-  cli_option("--disk", help="Disk information",
-             default=[], dest="disks",
-             action="append",
-             type="identkeyval"),
+  DISK_OPT,
   NET_OPT,
   NONICS_OPT,
   NWSYNC_OPT,
@@ -1525,16 +1522,8 @@ commands = {
                     "[-s|-p|-n NODE|-I NAME] <instance>",
                     "Replaces all disks for the instance"),
   'modify': (SetInstanceParams, ARGS_ONE_INSTANCE,
-             [DEBUG_OPT, FORCE_OPT,
-              HVOPTS_OPT,
-              BACKEND_OPT,
-              cli_option("--disk", help="Disk changes",
-                         default=[], dest="disks",
-                         action="append",
-                         type="identkeyval"),
-              NET_OPT,
-              SUBMIT_OPT,
-              ],
+             [BACKEND_OPT, DEBUG_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT,
+              NET_OPT, SUBMIT_OPT],
              "<instance>", "Alters the parameters of an instance"),
   'shutdown': (ShutdownInstance, [ArgInstance(min=1)],
                [DEBUG_OPT, m_node_opt, m_pri_node_opt, m_sec_node_opt,
-- 
GitLab