3 local cur prev base_cmd cmds ilist nlist
8 # The basic options we'll complete.
10 cmds="export import list remove"
12 # default completion is empty
15 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
16 # cluster not initialized
20 ilist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_instance_list")
21 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
25 # complete the command name
26 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
29 # we're doing options to commands
30 base_cmd="${COMP_WORDS[1]}"
35 # options or instances
36 COMPREPLY=( $(compgen -W "--no-shutdown -n $ilist" -- ${cur}) )
39 # if previous was option, we allow instance
42 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
50 COMPREPLY=( $(compgen -W "diskless file plain drbd" -- ${cur}) )
53 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
56 COMPREPLY=( $(compgen -W "loop blktap" -- ${cur}) )
59 # arguments to other options, we don't have completion yet
62 COMPREPLY=( $(compgen -W "-t -n -B -H -s --disks --net \
63 --no-nics --no-start --no-ip-check -I \
64 --src-node --src-dir --file-driver \
65 --file-storage-dir" -- ${cur}) )
70 if [[ "$COMP_CWORD" -eq 2 ]]; then
71 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
80 complete -F _gnt_backup gnt-backup
88 # The basic options we'll complete.
90 if [[ -e "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
91 cmds="add-tags command copyfile destroy getmaster info list-tags \
92 masterfailover modify queue redist-conf remove-tags rename \
93 search-tags verify verify-disks version"
98 # default completion is empty
100 case "$COMP_CWORD" in
102 # complete the command name
103 COMPREPLY=($(compgen -W "$cmds" -- ${cur}))
106 # complete arguments to the command
109 COMPREPLY=( $(compgen -W "drain undrain info" -- ${cur}) )
119 complete -F _gnt_cluster gnt-cluster
127 cmds="allocator delay submit-job"
129 # default completion is empty
132 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
133 # cluster not initialized
137 case "$COMP_CWORD" in
139 # complete the command name
140 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
143 # we're doing options to commands
144 base_cmd="${COMP_WORDS[1]}"
145 case "${base_cmd}" in
147 if [[ "$prev" != -* ]]; then
148 COMPREPLY=( $(compgen -W "--no-master -n" -- ${cur}) )
152 if [[ "$COMP_CWORD" -eq 2 ]]; then
153 COMPREPLY=( $(compgen -f -- ${cur}) )
162 complete -F _gnt_debug gnt-debug
166 local cur prev base_cmd cmds ilist nlist
171 # The basic options we'll complete.
173 cmds="activate-disks add add-tags batch-create console deactivate-disks \
174 failover grow-disk info list list-tags migrate modify reboot \
175 reinstall remove remove-tags rename replace-disks shutdown startup"
177 # default completion is empty
180 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
181 # cluster not initialized
185 ilist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_instance_list")
186 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
188 case "$COMP_CWORD" in
190 # complete the command name
191 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
194 # we're doing options to commands
195 base_cmd="${COMP_WORDS[1]}"
196 case "${base_cmd}" in
197 # first, rules for multiple commands
198 activate-disks|console|deactivate-disks|list-tags|rename|remove)
199 # commands with only one instance argument, nothing else
200 if [[ "$COMP_CWORD" -eq 2 ]]; then
201 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
205 # commands with more than one instance
206 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
208 add-tags|grow-disk|reinstall|remove-tags|replace-disks)
209 # not very well handled
210 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
212 startup|start|shutdown|stop|reboot)
213 COMPREPLY=( $(compgen -W "--force-multiple --node --primary \
214 --secondary --all --submit $ilist" -- ${cur}) )
216 # individual commands
220 COMPREPLY=( $(compgen -W "diskless file plain drbd" -- ${cur}) )
223 COMPREPLY=( $(compgen -W "loop blktap" -- ${cur}) )
226 # arguments to other options, we don't have completion yet
229 COMPREPLY=( $(compgen -W "-t -n -o -B -H -s --disks --net \
230 --no-nics --no-start --no-ip-check -I \
231 --file-driver --file-storage-dir --submit" \
237 # this only takes one file name
238 COMPREPLY=( $(compgen -A file -- ${cur}) )
241 case "$COMP_CWORD" in
243 # options or instances
244 COMPREPLY=( $(compgen -W "--ignore-failures $ilist" -- ${cur}) )
247 # if previous was option, we allow instance
250 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
256 COMPREPLY=( $(compgen -W "--no-headers --separator --units -o \
257 --sync $ilist" -- ${cur}) )
260 COMPREPLY=( $(compgen -W "-H -B --disk --net $ilist" -- ${cur}) )
263 case "$COMP_CWORD" in
265 # options or instances
266 COMPREPLY=( $(compgen -W "--non-live --cleanup $ilist" -- \
270 # if previous was option, we allow instance
273 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
283 complete -F _gnt_instance gnt-instance
291 cmds="archive autoarchive cancel info list"
293 # default completion is empty
296 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
297 # cluster not initialized
301 case "$COMP_CWORD" in
303 # complete the command name
304 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
307 # we're doing options to commands
308 base_cmd="${COMP_WORDS[1]}"
309 case "${base_cmd}" in
311 # FIXME: this is really going into the internals of the job queue
312 jlist=$( cd @LOCALSTATEDIR@/lib/ganeti/queue; echo job-*)
313 jlist=${jlist//job-/}
314 COMPREPLY=( $(compgen -W "$jlist" -- ${cur}) )
317 COMPREPLY=( $(compgen -W "--no-headers --separator -o" -- ${cur}) )
326 complete -F _gnt_job gnt-job
336 # default completion is empty
339 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
340 # cluster not initialized
344 case "$COMP_CWORD" in
346 # complete the command name
347 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
350 # we're doing options to commands
351 base_cmd="${COMP_WORDS[1]}"
352 case "${base_cmd}" in
354 if [[ "$COMP_CWORD" -eq 2 ]]; then
355 COMPREPLY=( $(compgen -W "--no-headers" -- ${cur}) )
364 complete -F _gnt_os gnt-os
368 local cur prev cmds base_cmd
372 cmds="add add-tags evacuate failover info list list-tags migrate modify \
373 remove remove-tags volumes"
375 # default completion is empty
378 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
379 # cluster not initialized
383 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
385 case "$COMP_CWORD" in
387 # complete the command name
388 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
391 # we're doing options to commands
392 base_cmd="${COMP_WORDS[1]}"
393 case "${base_cmd}" in
394 # first rules for multiple commands
396 # commands with only one instance argument, nothing else
397 if [[ "$COMP_CWORD" -eq 2 ]]; then
398 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
401 add-tags|info|remove-tags|volumes)
402 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
404 # individual commands
406 # options or instances
407 COMPREPLY=( $(compgen -W "-s --readd --no-ssh-key-check" -- ${cur}) )
410 case "$COMP_CWORD" in
412 # options or instances
413 COMPREPLY=( $(compgen -W "-n -I $nlist" -- ${cur}) )
416 # if previous was option, we allow node
419 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
425 case "$COMP_CWORD" in
427 # options or instances
428 COMPREPLY=( $(compgen -W "--ignore-failures $nlist" -- ${cur}) )
431 # if previous was option, we allow node
434 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
440 COMPREPLY=( $(compgen -W "--no-headers --separator --units -o \
441 --sync $nlist" -- ${cur}) )
444 # TODO: after a non-option, don't allow options
445 if [[ "$COMP_CWORD" -eq 2 || "$prev" != -* ]]; then
446 COMPREPLY=( $(compgen -W "-C -O -D $nlist" -- ${cur}) )
447 elif [[ "$prev" == -* ]]; then
448 COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
452 case "$COMP_CWORD" in
455 COMPREPLY=( $(compgen -W "--non-live $nlist" -- ${cur}) )
458 # if previous was option, we allow node
461 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
471 complete -F _gnt_node gnt-node
481 # default completion is empty
484 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
485 # cluster not initialized
489 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
493 COMPREPLY=( $(compgen -W "diskless file plain drbd" -- ${cur}) )
496 # this needs an unused host name, so we don't complete it
499 # nodes from the cluster, comma separated
500 # FIXME: make completion work for comma-separated values
501 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
505 COMPREPLY=( $(compgen -W "$(gnt-os list --no-headers)" -- ${cur}) )
507 --disk-size|--disk-growth)
508 # these take a number or unit, we can't really autocomplete, but
509 # we show a couple of examples
510 COMPREPLY=( $(compgen -W "128M 512M 1G 4G 1G,256M 4G,1G,1G 10G" -- \
514 # this takes a number or unit, we can't really autocomplete, but
515 # we show a couple of examples
516 COMPREPLY=( $(compgen -W "128M 256M 512M 1G 4G 8G 12G 16G" -- ${cur}) )
519 # this takes a number in seconds; again, we can't really complete
520 COMPREPLY=( $(compgen -W "15 60 300 900" -- ${cur}) )
523 # all other, we just list the whole options
524 COMPREPLY=( $(compgen -W "-o --disk-size --disk-growth --mem-size \
525 -v --verbose --no-replace1 --no-replace2 --no-failover \
526 --no-migrate --no-importexport --no-startstop \
527 --no-reinstall --no-reboot --no-activate-disks \
528 --no-add-disks --no-add-nics --no-nics \
529 --rename -t -n --nodes -I --iallocator -p --parallel \
530 --net-timeout -C --http-check -K --keep-instances" \
537 complete -F _gnt_tool_burnin @PREFIX@/lib/ganeti/tools/burnin