---
lib/cli.py | 7 +++++++
scripts/gnt-backup | 7 +------
scripts/gnt-cluster | 12 +++---------
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/lib/cli.py b/lib/cli.py
index bebe52e..f242a4a 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -61,6 +61,7 @@ __all__ = [
"IGNORE_CONSIST_OPT",
"FORCE_OPT",
"NET_OPT",
+ "NODE_LIST_OPT",
"NODE_PLACEMENT_OPT",
"NOHDR_OPT",
"NOIPCHECK_OPT",
@@ -580,6 +581,12 @@ NODE_PLACEMENT_OPT = cli_option("-n", "--node",
dest="node",
metavar="<pnode>[:<snode>]",
completion_suggest=OPT_COMPL_INST_ADD_NODES)
+NODE_LIST_OPT = cli_option("-n", "--node", dest="nodes", default=[],
+ action="append", metavar="<node>",
+ help="Use only this node (can be used multiple"
+ " times, if not given defaults to all nodes)",
+ completion_suggest=OPT_COMPL_ONE_NODE)
+
def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments.
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index ecca744..5f5bff9 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -233,12 +233,7 @@ import_opts = [
commands = {
'list': (PrintExportList, ARGS_NONE,
- [DEBUG_OPT,
- cli_option("--node", dest="nodes", default=[], action="append",
- help="List only backups stored on this node"
- " (can be used multiple times)",
- completion_suggest=OPT_COMPL_ONE_NODE),
- ],
+ [DEBUG_OPT, NODE_LIST_OPT],
"", "Lists instance exports available in the ganeti cluster"),
'export': (ExportInstance, ARGS_ONE_INSTANCE,
[DEBUG_OPT, FORCE_OPT,
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index 33ddd76..f939e30 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -586,13 +586,6 @@ def WatcherOps(opts, args):
return 0
-# this is an option common to more than one command, so we declare
-# it here and reuse it
-node_option = cli_option("-n", "--node", action="append", dest="nodes",
- help="Node to copy to (if not given, all nodes),"
- " can be given multiple times",
- metavar="<node>", default=[])
-
commands = {
'init': (InitCluster, [ArgHost(min=1, max=1)],
[DEBUG_OPT,
@@ -688,10 +681,11 @@ commands = {
'getmaster': (ShowClusterMaster, ARGS_NONE, [DEBUG_OPT],
"", "Shows the cluster master"),
'copyfile': (ClusterCopyFile, [ArgFile(min=1, max=1)],
- [DEBUG_OPT, node_option],
+ [DEBUG_OPT, NODE_LIST_OPT],
"[-n node...] <filename>",
"Copies a file to all (or only some) nodes"),
- 'command': (RunClusterCommand, [ArgCommand(min=1)], [DEBUG_OPT, node_option],
+ 'command': (RunClusterCommand, [ArgCommand(min=1)],
+ [DEBUG_OPT, NODE_LIST_OPT],
"[-n node...] <command>",
"Runs a command on all (or only some) nodes"),
'info': (ShowClusterConfig, ARGS_NONE, [DEBUG_OPT],
--
1.6.3.3