From a14db5ffcbd4b575c3a459110d432f7b29032ed2 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 17 Sep 2009 13:36:18 +0200
Subject: [PATCH] =?UTF-8?q?Unify=20the=20=E2=80=9C--new-secondary=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: Michael Hanselmann <hansmi@google.com>
---
 lib/cli.py           | 6 ++++++
 scripts/gnt-instance | 8 ++------
 scripts/gnt-node     | 7 +------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 341216596..b56bfb928 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -64,6 +64,7 @@ __all__ = [
   "IGNORE_FAILURES_OPT",
   "FORCE_OPT",
   "NET_OPT",
+  "NEW_SECONDARY_OPT",
   "NODE_LIST_OPT",
   "NODE_PLACEMENT_OPT",
   "NOHDR_OPT",
@@ -636,6 +637,11 @@ IGNORE_FAILURES_OPT = cli_option("--ignore-failures", dest="ignore_failures",
                                  " configuration even if there are failures"
                                  " during the removal process")
 
+NEW_SECONDARY_OPT = cli_option("-n", "--new-secondary", dest="dst_node",
+                               help="Specifies the new secondary node",
+                               metavar="NODE", default=None,
+                               completion_suggest=OPT_COMPL_ONE_NODE)
+
 
 def _ParseArgs(argv, commands, aliases):
   """Parser for the command line arguments.
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 1d1976f87..fcbecd2b1 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -845,7 +845,7 @@ def ReplaceDisks(opts, args):
 
   """
   instance_name = args[0]
-  new_2ndary = opts.new_secondary
+  new_2ndary = opts.dst_node
   iallocator = opts.iallocator
   if opts.disks is None:
     disks = []
@@ -1436,11 +1436,7 @@ commands = {
              "<instance> <new_name>", "Rename the instance"),
   'replace-disks': (ReplaceDisks, ARGS_ONE_INSTANCE,
                     [DEBUG_OPT,
-                     cli_option("-n", "--new-secondary", dest="new_secondary",
-                                help=("New secondary node (for secondary"
-                                      " node change)"), metavar="NODE",
-                                default=None,
-                                completion_suggest=OPT_COMPL_ONE_NODE),
+                     NEW_SECONDARY_OPT,
                      cli_option("-p", "--on-primary", dest="on_primary",
                                 default=False, action="store_true",
                                 help=("Replace the disk(s) on the primary"
diff --git a/scripts/gnt-node b/scripts/gnt-node
index baf46f108..75dca8666 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -637,12 +637,7 @@ commands = {
           "[-s ip] [--readd] [--no-ssh-key-check] <node_name>",
           "Add a node to the cluster"),
   'evacuate': (EvacuateNode, ARGS_ONE_NODE,
-               [DEBUG_OPT, FORCE_OPT, IALLOCATOR_OPT,
-                cli_option("-n", "--new-secondary", dest="dst_node",
-                           help="New secondary node", metavar="NODE",
-                           default=None,
-                           completion_suggest=OPT_COMPL_ONE_NODE),
-                ],
+               [DEBUG_OPT, FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT],
                "[-f] {-I <iallocator> | -n <dst>} <node>",
                "Relocate the secondary instances from a node"
                " to other nodes (only for instances with drbd disk template)"),
-- 
GitLab