From 3f75b4f32178ca6d83fed4304dc8dc41eb653f61 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 10:57:03 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--no-wait-for-sync?=
 =?UTF-8?q?=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           |  5 +++++
 scripts/gnt-backup   |  3 +--
 scripts/gnt-instance | 10 ++--------
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 26a4b4d40..bbe5158b3 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -50,6 +50,7 @@ __all__ = [
   "FIELDS_OPT",
   "FORCE_OPT",
   "NOHDR_OPT",
+  "NWSYNC_OPT",
   "SEP_OPT",
   "SUBMIT_OPT",
   "SYNC_OPT",
@@ -470,6 +471,10 @@ DEBUG_SIMERR_OPT = cli_option("--debug-simulate-errors", default=False,
                               help="Debugging option that makes the operation"
                               " treat most runtime checks as failed")
 
+NWSYNC_OPT = cli_option("--no-wait-for-sync", dest="wait_for_sync",
+                        default=True, action="store_false",
+                        help="Don't wait for sync (DANGEROUS!)")
+
 
 def _ParseArgs(argv, commands, aliases):
   """Parser for the command line arguments.
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index 12a667dfb..a45256f74 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -236,8 +236,7 @@ import_opts = [
              type="identkeyval"),
   cli_option("--no-nics", default=False, action="store_true",
              help="Do not create any network cards for the instance"),
-  cli_option("--no-wait-for-sync", dest="wait_for_sync", default=True,
-             action="store_false", help="Don't wait for sync (DANGEROUS!)"),
+  NWSYNC_OPT,
   cli_option("--src-node", dest="src_node", help="Source node",
              metavar="<node>",
              completion_suggest=OPT_COMPL_ONE_NODE),
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 498061447..256b39a4c 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -1393,8 +1393,7 @@ add_opts = [
              type="identkeyval"),
   cli_option("--no-nics", default=False, action="store_true",
              help="Do not create any network cards for the instance"),
-  cli_option("--no-wait-for-sync", dest="wait_for_sync", default=True,
-             action="store_false", help="Don't wait for sync (DANGEROUS!)"),
+  NWSYNC_OPT,
   cli_option("--no-start", dest="start", default=True,
              action="store_false", help="Don't start the instance after"
              " creation"),
@@ -1642,12 +1641,7 @@ commands = {
   'grow-disk': (GrowDisk,
                 [ArgInstance(min=1, max=1), ArgUnknown(min=1, max=1),
                  ArgUnknown(min=1, max=1)],
-                [DEBUG_OPT, SUBMIT_OPT,
-                 cli_option("--no-wait-for-sync",
-                            dest="wait_for_sync", default=True,
-                            action="store_false",
-                            help="Don't wait for sync (DANGEROUS!)"),
-                 ],
+                [DEBUG_OPT, SUBMIT_OPT, NWSYNC_OPT],
                 "<instance> <disk> <size>", "Grow an instance's disk"),
   'list-tags': (ListTags, ARGS_ONE_INSTANCE, [DEBUG_OPT],
                 "<instance_name>", "List the tags of the given instance"),
-- 
GitLab