From 7d3a9faba965b16fc0b076def484893233bbc2d7 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 12:36:54 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--net=E2=80=9D=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 | 10 ++--------
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index c81bf5485..7d69b7024 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -57,6 +57,7 @@ __all__ = [
   "HYPERVISOR_OPT",
   "IALLOCATOR_OPT",
   "FORCE_OPT",
+  "NET_OPT",
   "NOHDR_OPT",
   "NOIPCHECK_OPT",
   "NONICS_OPT",
@@ -539,6 +540,9 @@ NOIPCHECK_OPT = cli_option("--no-ip-check", dest="ip_check", default=True,
                            help="Don't check that the instance's IP"
                            " is alive")
 
+NET_OPT = cli_option("--net",
+                     help="NIC parameters", default=[],
+                     dest="nics", action="append", type="identkeyval")
 
 
 def _ParseArgs(argv, commands, aliases):
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index a1bb6e64b..cdcddac84 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -225,10 +225,7 @@ import_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("--net", help="NIC information",
-             default=[], dest="nics",
-             action="append",
-             type="identkeyval"),
+  NET_OPT,
   NONICS_OPT,
   NWSYNC_OPT,
   cli_option("--src-node", dest="src_node", help="Source node",
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index d3c389515..b042f0f25 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -1378,10 +1378,7 @@ add_opts = [
              default=[], dest="disks",
              action="append",
              type="identkeyval"),
-  cli_option("--net", help="NIC information",
-             default=[], dest="nics",
-             action="append",
-             type="identkeyval"),
+  NET_OPT,
   NONICS_OPT,
   NWSYNC_OPT,
   cli_option("--no-start", dest="start", default=True,
@@ -1535,10 +1532,7 @@ commands = {
                          default=[], dest="disks",
                          action="append",
                          type="identkeyval"),
-              cli_option("--net", help="NIC changes",
-                         default=[], dest="nics",
-                         action="append",
-                         type="identkeyval"),
+              NET_OPT,
               SUBMIT_OPT,
               ],
              "<instance>", "Alters the parameters of an instance"),
-- 
GitLab