diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion index efb381f7aed893cc823655b743ef73131b9575b5..b0465439e77dba5a932a391a8dc2e340e23b3f54 100755 --- a/autotools/build-bash-completion +++ b/autotools/build-bash-completion @@ -117,6 +117,15 @@ def WritePreamble(sw): sw.DecIndent() sw.Write("}") + sw.Write("_ganeti_nodegroup() {") + sw.IncIndent() + try: + nodegroups_path = os.path.join(constants.DATA_DIR, "ssconf_nodegroups") + sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(nodegroups_path)) + finally: + sw.DecIndent() + sw.Write("}") + # Params: <offset> <options with values> <options without values> # Result variable: $first_arg_idx sw.Write("_ganeti_find_first_arg() {") @@ -324,6 +333,8 @@ class CompletionWriter: WriteCompReply(sw, "-W \"$(_ganeti_os)\"", cur=cur) elif suggest == cli.OPT_COMPL_ONE_IALLOCATOR: WriteCompReply(sw, "-W \"$(_ganeti_iallocator)\"", cur=cur) + elif suggest == cli.OPT_COMPL_ONE_NODEGROUP: + WriteCompReply(sw, "-W \"$(_ganeti_nodegroup)\"", cur=cur) elif suggest == cli.OPT_COMPL_INST_ADD_NODES: sw.Write("local tmp= node1= pfx= curvalue=\"${optcur#*:}\"") diff --git a/lib/cli.py b/lib/cli.py index ad8e9a7fc65ccaaae71a266cbbffb4c1aabfd08c..14c6c928924982caeb4b859b79b979715841fc5c 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -194,6 +194,7 @@ __all__ = [ "OPT_COMPL_ONE_IALLOCATOR", "OPT_COMPL_ONE_INSTANCE", "OPT_COMPL_ONE_NODE", + "OPT_COMPL_ONE_NODEGROUP", "OPT_COMPL_ONE_OS", "cli_option", "SplitNodeOption", @@ -515,7 +516,8 @@ def check_bool(option, opt, value): # pylint: disable-msg=W0613 OPT_COMPL_ONE_INSTANCE, OPT_COMPL_ONE_OS, OPT_COMPL_ONE_IALLOCATOR, - OPT_COMPL_INST_ADD_NODES) = range(100, 106) + OPT_COMPL_INST_ADD_NODES, + OPT_COMPL_ONE_NODEGROUP) = range(100, 107) OPT_COMPL_ALL = frozenset([ OPT_COMPL_MANY_NODES, @@ -524,6 +526,7 @@ OPT_COMPL_ALL = frozenset([ OPT_COMPL_ONE_OS, OPT_COMPL_ONE_IALLOCATOR, OPT_COMPL_INST_ADD_NODES, + OPT_COMPL_ONE_NODEGROUP, ])