diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion index befbe6b722a5e55f9a3ede4fddc9aa69853c7c27..57729dd68a62f38f5f48cce4c033e03bc0ff65c7 100755 --- a/autotools/build-bash-completion +++ b/autotools/build-bash-completion @@ -321,6 +321,9 @@ class CompletionWriter: elif isinstance(arg, cli.ArgCommand): choices = "" compgenargs.append("-c") + elif isinstance(arg, cli.ArgHost): + choices = "" + compgenargs.append("-A hostname") else: raise Exception("Unknown argument type %r" % arg) diff --git a/lib/cli.py b/lib/cli.py index b47368282b4e6c30bd68f6ec5ae672dcf6c4ee21..cee7e2bbf2b2fb78c57e5efe427464f6f0798534 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -53,7 +53,7 @@ __all__ = ["DEBUG_OPT", "NOHDR_OPT", "SEP_OPT", "GenericMain", "ToStderr", "ToStdout", "UsesRPC", "GetOnlineNodes", "JobExecutor", "SYNC_OPT", "CONFIRM_OPT", "ArgJobId", "ArgSuggest", "ArgUnknown", "ArgFile", "ArgCommand", - "ArgInstance", "ArgNode", "ArgChoice", + "ArgInstance", "ArgNode", "ArgChoice", "ArgHost", "ARGS_NONE", "ARGS_ONE_INSTANCE", "ARGS_ONE_NODE", "ARGS_MANY_INSTANCES", "ARGS_MANY_NODES", ] @@ -131,6 +131,12 @@ class ArgCommand(_Argument): """ +class ArgHost(_Argument): + """Host argument. + + """ + + ARGS_NONE = [] ARGS_MANY_INSTANCES = [ArgInstance()] ARGS_MANY_NODES = [ArgNode()] diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 0c9bccd173e8a3b8f293708d46fb148411a825ca..ec0be431ca097cb7db7896d71a2a67db680fbeb4 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -541,7 +541,7 @@ node_option = cli_option("-n", "--node", action="append", dest="nodes", metavar="<node>", default=[]) commands = { - 'init': (InitCluster, [ArgUnknown(min=1, max=1)], + 'init': (InitCluster, [ArgHost(min=1, max=1)], [DEBUG_OPT, cli_option("-s", "--secondary-ip", dest="secondary_ip", help="Specify the secondary ip for this node;" @@ -608,7 +608,7 @@ commands = { action="store_true"), ], "", "Destroy cluster"), - 'rename': (RenameCluster, [ArgUnknown(min=1, max=1)], + 'rename': (RenameCluster, [ArgHost(min=1, max=1)], [DEBUG_OPT, FORCE_OPT], "<new_name>", "Renames the cluster"), diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 6280413c91af1c2bbef2f1b7306305d5f34175bc..d0a0c807f13f780fe502d966b1e3721264cb497d 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -1418,7 +1418,7 @@ add_opts = [ ] commands = { - 'add': (AddInstance, [ArgUnknown(min=1, max=1)], add_opts, + 'add': (AddInstance, [ArgHost(min=1, max=1)], add_opts, "[...] -t disk-type -n node[:secondary-node] -o os-type <name>", "Creates and adds a new instance to the cluster"), 'batch-create': (BatchCreate, [ArgFile(min=1, max=1)], @@ -1517,7 +1517,7 @@ commands = { ], "[-f] <instance>", "Shuts down the instance and removes it"), 'rename': (RenameInstance, - [ArgInstance(min=1, max=1), ArgUnknown(min=1, max=1)], + [ArgInstance(min=1, max=1), ArgHost(min=1, max=1)], [DEBUG_OPT, cli_option("--no-ip-check", dest="ignore_ip", help="Do not check that the IP of the new name" diff --git a/scripts/gnt-node b/scripts/gnt-node index cffa1d9726086e3538651163b1291c4eba6d9222..6aa57f2961d3b930f46e0a696b256f8626e7acf9 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -622,7 +622,7 @@ def SetNodeParams(opts, args): commands = { - 'add': (AddNode, [ArgUnknown(min=1, max=1)], + 'add': (AddNode, [ArgHost(min=1, max=1)], [DEBUG_OPT, cli_option("-s", "--secondary-ip", dest="secondary_ip", help="Specify the secondary ip for the node",