Skip to content
Snippets Groups Projects
Commit c1439c1c authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos
Browse files

Make bash completion network-aware


Signed-off-by: default avatarApollon Oikonomopoulos <apollon@noc.grnet.gr>
parent 2d25bcdf
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,15 @@ def WritePreamble(sw):
sw.DecIndent()
sw.Write("}")
sw.Write("_ganeti_network() {")
sw.IncIndent()
try:
networks_path = os.path.join(constants.DATA_DIR, "ssconf_networks")
sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(networks_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() {")
......@@ -339,6 +348,8 @@ class CompletionWriter:
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_ONE_NETWORK:
WriteCompReply(sw, "-W \"$(_ganeti_network)\"", cur=cur)
elif suggest == cli.OPT_COMPL_INST_ADD_NODES:
sw.Write("local tmp= node1= pfx= curvalue=\"${optcur#*:}\"")
......@@ -440,6 +451,8 @@ class CompletionWriter:
choices = "$(_ganeti_nodes)"
elif isinstance(arg, cli.ArgGroup):
choices = "$(_ganeti_nodegroup)"
elif isinstance(arg, cli.ArgNetwork):
choices = "$(_ganeti_network)"
elif isinstance(arg, cli.ArgJobId):
choices = "$(_ganeti_jobs)"
elif isinstance(arg, cli.ArgOs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment