Commit 7edc4637 authored by Iustin Pop's avatar Iustin Pop

Unify the “--node” (as list of nodes) option

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 990b7886
......@@ -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.
......
......@@ -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,
......
......@@ -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],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment