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}) )
112 COMPREPLY=( $(compgen -f -- ${cur}) )
115 COMPREPLY=( $(compgen -c -- ${cur}) )
125 complete -F _gnt_cluster gnt-cluster
133 cmds="allocator delay submit-job"
135 # default completion is empty
138 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
139 # cluster not initialized
143 case "$COMP_CWORD" in
145 # complete the command name
146 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
149 # we're doing options to commands
150 base_cmd="${COMP_WORDS[1]}"
151 case "${base_cmd}" in
153 if [[ "$prev" != -* ]]; then
154 COMPREPLY=( $(compgen -W "--no-master -n" -- ${cur}) )
158 if [[ "$COMP_CWORD" -eq 2 ]]; then
159 COMPREPLY=( $(compgen -f -- ${cur}) )
168 complete -F _gnt_debug gnt-debug
172 local cur prev base_cmd cmds ilist nlist
177 # The basic options we'll complete.
179 cmds="activate-disks add add-tags batch-create console deactivate-disks \
180 failover grow-disk info list list-tags migrate modify reboot \
181 reinstall remove remove-tags rename replace-disks shutdown startup"
183 # default completion is empty
186 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
187 # cluster not initialized
191 ilist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_instance_list")
192 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
194 case "$COMP_CWORD" in
196 # complete the command name
197 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
200 # we're doing options to commands
201 base_cmd="${COMP_WORDS[1]}"
202 case "${base_cmd}" in
203 # first, rules for multiple commands
204 activate-disks|console|deactivate-disks|list-tags|rename|remove)
205 # commands with only one instance argument, nothing else
206 if [[ "$COMP_CWORD" -eq 2 ]]; then
207 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
211 # commands with more than one instance
212 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
214 add-tags|grow-disk|reinstall|remove-tags|replace-disks)
215 # not very well handled
216 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
218 startup|start|shutdown|stop|reboot)
219 COMPREPLY=( $(compgen -W "--force-multiple --node --primary \
220 --secondary --all --submit $ilist" -- ${cur}) )
222 # individual commands
226 COMPREPLY=( $(compgen -W "diskless file plain drbd" -- ${cur}) )
229 COMPREPLY=( $(compgen -W "loop blktap" -- ${cur}) )
232 # arguments to other options, we don't have completion yet
235 COMPREPLY=( $(compgen -W "-t -n -o -B -H -s --disks --net \
236 --no-nics --no-start --no-ip-check -I \
237 --file-driver --file-storage-dir --submit" \
243 # this only takes one file name
244 COMPREPLY=( $(compgen -A file -- ${cur}) )
247 case "$COMP_CWORD" in
249 # options or instances
250 COMPREPLY=( $(compgen -W "--ignore-failures $ilist" -- ${cur}) )
253 # if previous was option, we allow instance
256 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
262 COMPREPLY=( $(compgen -W "--no-headers --separator --units -o \
263 --sync $ilist" -- ${cur}) )
266 COMPREPLY=( $(compgen -W "-H -B --disk --net $ilist" -- ${cur}) )
269 case "$COMP_CWORD" in
271 # options or instances
272 COMPREPLY=( $(compgen -W "--non-live --cleanup $ilist" -- \
276 # if previous was option, we allow instance
279 COMPREPLY=( $(compgen -W "$ilist" -- ${cur}) )
289 complete -F _gnt_instance gnt-instance
297 cmds="archive autoarchive cancel info list"
299 # default completion is empty
302 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
303 # cluster not initialized
307 case "$COMP_CWORD" in
309 # complete the command name
310 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
313 # we're doing options to commands
314 base_cmd="${COMP_WORDS[1]}"
315 case "${base_cmd}" in
317 # FIXME: this is really going into the internals of the job queue
318 jlist=$( cd @LOCALSTATEDIR@/lib/ganeti/queue; echo job-*)
319 jlist=${jlist//job-/}
320 COMPREPLY=( $(compgen -W "$jlist" -- ${cur}) )
323 COMPREPLY=( $(compgen -W "--no-headers --separator -o" -- ${cur}) )
332 complete -F _gnt_job gnt-job
342 # default completion is empty
345 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
346 # cluster not initialized
350 case "$COMP_CWORD" in
352 # complete the command name
353 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
356 # we're doing options to commands
357 base_cmd="${COMP_WORDS[1]}"
358 case "${base_cmd}" in
360 if [[ "$COMP_CWORD" -eq 2 ]]; then
361 COMPREPLY=( $(compgen -W "--no-headers" -- ${cur}) )
370 complete -F _gnt_os gnt-os
374 local cur prev cmds base_cmd
378 cmds="add add-tags evacuate failover info list list-tags migrate modify \
379 remove remove-tags volumes"
381 # default completion is empty
384 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
385 # cluster not initialized
389 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
391 case "$COMP_CWORD" in
393 # complete the command name
394 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
397 # we're doing options to commands
398 base_cmd="${COMP_WORDS[1]}"
399 case "${base_cmd}" in
400 # first rules for multiple commands
402 # commands with only one instance argument, nothing else
403 if [[ "$COMP_CWORD" -eq 2 ]]; then
404 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
407 add-tags|info|remove-tags|volumes)
408 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
410 # individual commands
412 # options or instances
413 COMPREPLY=( $(compgen -W "-s --readd --no-ssh-key-check" -- ${cur}) )
416 case "$COMP_CWORD" in
418 # options or instances
419 COMPREPLY=( $(compgen -W "-n -I $nlist" -- ${cur}) )
422 # if previous was option, we allow node
425 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
431 case "$COMP_CWORD" in
433 # options or instances
434 COMPREPLY=( $(compgen -W "--ignore-failures $nlist" -- ${cur}) )
437 # if previous was option, we allow node
440 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
446 COMPREPLY=( $(compgen -W "--no-headers --separator --units -o \
447 --sync $nlist" -- ${cur}) )
450 # TODO: after a non-option, don't allow options
451 if [[ "$COMP_CWORD" -eq 2 || "$prev" != -* ]]; then
452 COMPREPLY=( $(compgen -W "-C -O -D $nlist" -- ${cur}) )
453 elif [[ "$prev" == -* ]]; then
454 COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
458 case "$COMP_CWORD" in
461 COMPREPLY=( $(compgen -W "--non-live $nlist" -- ${cur}) )
464 # if previous was option, we allow node
467 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
477 complete -F _gnt_node gnt-node
487 # default completion is empty
490 if [[ ! -f "@LOCALSTATEDIR@/lib/ganeti/ssconf_cluster_name" ]]; then
491 # cluster not initialized
495 nlist=$(< "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_list")
499 COMPREPLY=( $(compgen -W "diskless file plain drbd" -- ${cur}) )
502 # this needs an unused host name, so we don't complete it
505 # nodes from the cluster, comma separated
506 # FIXME: make completion work for comma-separated values
507 COMPREPLY=( $(compgen -W "$nlist" -- ${cur}) )
511 COMPREPLY=( $(compgen -W "$(gnt-os list --no-headers)" -- ${cur}) )
513 --disk-size|--disk-growth)
514 # these take a number or unit, we can't really autocomplete, but
515 # we show a couple of examples
516 COMPREPLY=( $(compgen -W "128M 512M 1G 4G 1G,256M 4G,1G,1G 10G" -- \
520 # this takes a number or unit, we can't really autocomplete, but
521 # we show a couple of examples
522 COMPREPLY=( $(compgen -W "128M 256M 512M 1G 4G 8G 12G 16G" -- ${cur}) )
525 # this takes a number in seconds; again, we can't really complete
526 COMPREPLY=( $(compgen -W "15 60 300 900" -- ${cur}) )
529 # all other, we just list the whole options
530 COMPREPLY=( $(compgen -W "-o --disk-size --disk-growth --mem-size \
531 -v --verbose --no-replace1 --no-replace2 --no-failover \
532 --no-migrate --no-importexport --no-startstop \
533 --no-reinstall --no-reboot --no-activate-disks \
534 --no-add-disks --no-add-nics --no-nics \
535 --rename -t -n --nodes -I --iallocator -p --parallel \
536 --net-timeout -C --http-check -K --keep-instances" \
543 complete -F _gnt_tool_burnin @PREFIX@/lib/ganeti/tools/burnin