Commit 83ec7961 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add ArgHost class



It expands to the hostnames known by bash.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4a265c08
......@@ -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)
......
......@@ -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()]
......
......@@ -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"),
......
......@@ -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"
......
......@@ -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",
......
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