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_INST_ADD_NODES:
+ sw.Write("local tmp= node1= pfx= curvalue=\"${optcur#*:}\"")
+
+ sw.Write("if [[ \"$optcur\" == *:* ]]; then")
+ sw.IncIndent()
+ try:
+ sw.Write("node1=\"${optcur%%:*}\"")
+
+ sw.Write("if [[ \"$COMP_WORDBREAKS\" != *:* ]]; then")
+ sw.IncIndent()
+ try:
+ sw.Write("pfx=\"$node1:\"")
+ finally:
+ sw.DecIndent()
+ sw.Write("fi")
+ finally:
+ sw.DecIndent()
+ sw.Write("fi")
+
+ sw.Write("_ganeti_dbglog pfx=\"'$pfx'\" curvalue=\"'$curvalue'\""
+ " node1=\"'$node1'\"")
+
+ sw.Write("for i in $(_ganeti_nodes); do")
+ sw.IncIndent()
+ try:
+ sw.Write("if [[ -z \"$node1\" ]]; then")
+ sw.IncIndent()
+ try:
+ sw.Write("tmp=\"$tmp $i $i:\"")
+ finally:
+ sw.DecIndent()
+ sw.Write("elif [[ \"$i\" != \"$node1\" ]]; then")
+ sw.IncIndent()
+ try:
+ sw.Write("tmp=\"$tmp $i\"")
+ finally:
+ sw.DecIndent()
+ sw.Write("fi")
+ finally:
+ sw.DecIndent()
+ sw.Write("done")
+
+ WriteCompReply(sw, "-P \"$pfx\" -W \"$tmp\"", cur="\"$curvalue\"")
else:
WriteCompReply(sw, "-W %s" % utils.ShellQuote(suggest), cur=cur)
finally:
"OPT_COMPL_ONE_NODE", "OPT_COMPL_ONE_INSTANCE",
"OPT_COMPL_MANY_NODES",
"OPT_COMPL_ONE_OS", "OPT_COMPL_ONE_IALLOCATOR",
+ "OPT_COMPL_INST_ADD_NODES",
]
NO_PREFIX = "no_"
OPT_COMPL_ONE_NODE,
OPT_COMPL_ONE_INSTANCE,
OPT_COMPL_ONE_OS,
- OPT_COMPL_ONE_IALLOCATOR) = range(100, 105)
+ OPT_COMPL_ONE_IALLOCATOR,
+ OPT_COMPL_INST_ADD_NODES) = range(100, 106)
OPT_COMPL_ALL = frozenset([
OPT_COMPL_MANY_NODES,
OPT_COMPL_ONE_INSTANCE,
OPT_COMPL_ONE_OS,
OPT_COMPL_ONE_IALLOCATOR,
+ OPT_COMPL_INST_ADD_NODES,
])
DEBUG_OPT,
cli_option("-n", "--node", dest="node",
help="Target node and optional secondary node",
- metavar="<pnode>[:<snode>]"),
+ metavar="<pnode>[:<snode>]",
+ completion_suggest=OPT_COMPL_INST_ADD_NODES),
cli_option("-B", "--backend", dest="beparams",
type="keyval", default={},
help="Backend parameters"),
DEBUG_OPT,
cli_option("-n", "--node", dest="node",
help="Target node and optional secondary node",
- metavar="<pnode>[:<snode>]"),
+ metavar="<pnode>[:<snode>]",
+ completion_suggest=OPT_COMPL_INST_ADD_NODES),
os_opt,
cli_option("-B", "--backend", dest="beparams",
type="keyval", default={},