# This script is automatically generated at build time.
# Do not modify manually.
_ganeti_dbglog() {
  if [[ -n "$GANETI_COMPL_LOG" ]]; then
    {
      echo ---
      echo "$@"
      echo
    } >> $GANETI_COMPL_LOG
  fi
}
_ganeti_nodes() {
  cat /var/lib/ganeti/ssconf_node_list 2>/dev/null || :
}
_ganeti_instances() {
  cat /var/lib/ganeti/ssconf_instance_list 2>/dev/null || :
}
_ganeti_jobs() {
  local jlist=$( shopt -s nullglob && cd /var/lib/ganeti/queue 2>/dev/null && echo job-* || : )
  echo "${jlist//job-/}"
}
_ganeti_os() {
  ( shopt -s nullglob && cd /srv/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/local/lib/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/lib/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/share/ganeti/os 2>/dev/null && echo * || : )
}
_ganeti_iallocator() {
  ( shopt -s nullglob && cd /usr/local/lib/ganeti/iallocators 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/lib/ganeti/iallocators 2>/dev/null && echo * || : )
}
_ganeti_find_first_arg() {
  local w i
  first_arg_idx=
  for (( i=$1; i < COMP_CWORD; ++i )); do
    w=${COMP_WORDS[$i]}
    if [[ -n "$2" && "$w" == @($2) ]]; then let ++i
    elif [[ -n "$3" && "$w" == @($3) ]]; then :
    else first_arg_idx=$i; break;
    fi
  done
}
_ganeti_list_options() {
  if [[ -z "$first_arg_idx" ]]; then
    arg_idx=0
    if [[ "$cur" == -* ]]; then
      choices=$1
    fi
    return
  fi
  arg_idx=$(( COMP_CWORD - first_arg_idx ))
  choices=
}
_ganeti_checkopt() {
  if [[ -n "$1" && "$cur" == @($1) ]]; then
    optcur="${cur#--*=}"
    return 0
  elif [[ -n "$2" && "$prev" == @($2) ]]; then
    optcur="$cur"
    return 0
  fi
  _ganeti_dbglog optcur="'$optcur'"
  return 1
}
_ganeti_compgen() {
  COMPREPLY=( $(compgen "$@") )
  _ganeti_dbglog COMPREPLY="${COMPREPLY[@]}"
}
_gnt_backup() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'export import list remove' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  export)
    _ganeti_find_first_arg 2 '--node|--shutdown-timeout|-n' '--debug|--force|--help|--node=*|--noshutdown|--shutdown-timeout=*|-d|-f|-h'
    if _ganeti_checkopt '--shutdown-timeout=*' --shutdown-timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --node --noshutdown --shutdown-timeout -d -f -h -n'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--node|-n' '--debug|--help|--node=*|-d|-h'
    if _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --node -d -h -n'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgUnknown min=1 max=1>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  import)
    _ganeti_find_first_arg 2 '--backend-parameters|--disk|--disk-template|--file-driver|--file-storage-dir|--hypervisor-parameters|--iallocator|--net|--node|--os-size|--src-dir|--src-node|-B|-H|-I|-n|-s|-t' '--backend-parameters=*|--debug|--disk-template=*|--disk=*|--file-driver=*|--file-storage-dir=*|--help|--hypervisor-parameters=*|--iallocator=*|--identify-defaults|--net=*|--no-ip-check|--no-name-check|--no-nics|--no-wait-for-sync|--node=*|--os-size=*|--src-dir=*|--src-node=*|--submit|-d|-h'
    if _ganeti_checkopt '--backend-parameters=*|--disk=*|--file-storage-dir=*|--hypervisor-parameters=*|--net=*|--os-size=*|--src-dir=*' '--backend-parameters|-B|--disk|--file-storage-dir|--hypervisor-parameters|-H|--net|--os-size|-s|--src-dir'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--file-driver=*' --file-driver; then
      _ganeti_compgen -W 'blktap loop' -- "$optcur"
      return
    elif _ganeti_checkopt '--src-node=*' --src-node; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--node=*' '--node|-n'; then
      local tmp= node1= pfx= curvalue="${optcur#*:}"
      if [[ "$optcur" == *:* ]]; then
        node1="${optcur%%:*}"
        if [[ "$COMP_WORDBREAKS" != *:* ]]; then
          pfx="$node1:"
        fi
      fi
      _ganeti_dbglog pfx="'$pfx'" curvalue="'$curvalue'" node1="'$node1'"
      for i in $(_ganeti_nodes); do
        if [[ -z "$node1" ]]; then
          tmp="$tmp $i $i:"
        elif [[ "$i" != "$node1" ]]; then
          tmp="$tmp $i"
        fi
      done
      _ganeti_compgen -P "$pfx" -W "$tmp" -- "$curvalue"
      return
    elif _ganeti_checkopt '--disk-template=*' '--disk-template|-t'; then
      _ganeti_compgen -W 'diskless drbd file plain' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --debug --disk --disk-template --file-driver --file-storage-dir --help --hypervisor-parameters --iallocator --identify-defaults --net --no-ip-check --no-name-check --no-nics --no-wait-for-sync --node --os-size --src-dir --src-node --submit -B -H -I -d -h -n -s -t'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_backup -o filenames gnt-backup
_gnt_cluster() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'add-tags command copyfile destroy getmaster info init list-tags masterfailover modify queue redist-conf remove-tags rename renew-crypto repair-disk-sizes search-tags verify verify-disks version watcher' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  rename)
    _ganeti_find_first_arg 2 '' '--debug|--force|--help|-d|-f|-h'
    _ganeti_list_options '--debug --force --help -d -f -h'
    # 0: <ArgHost min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  copyfile)
    _ganeti_find_first_arg 2 '--node|-n' '--debug|--help|--node=*|--use-replication-network|-d|-h'
    if _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --node --use-replication-network -d -h -n'
    # 0: <ArgFile min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs=-f
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  verify-disks)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 '' '--debug|--help|--roman|-d|-h'
    _ganeti_list_options '--debug --help --roman -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  getmaster)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  search-tags)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgUnknown min=1 max=1>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  verify)
    _ganeti_find_first_arg 2 '' '--debug|--debug-simulate-errors|--error-codes|--help|--no-nplus1-mem|--verbose|-d|-h|-v'
    _ganeti_list_options '--debug --debug-simulate-errors --error-codes --help --no-nplus1-mem --verbose -d -h -v'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  repair-disk-sizes)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--add-uids|--backend-parameters|--candidate-pool-size|--enabled-hypervisors|--hypervisor-parameters|--maintain-node-health|--nic-parameters|--remove-uids|--uid-pool|--vg-name|-B|-C|-H|-N|-g' '--add-uids=*|--backend-parameters=*|--candidate-pool-size=*|--debug|--enabled-hypervisors=*|--help|--hypervisor-parameters=*|--maintain-node-health=*|--nic-parameters=*|--no-lvm-storage|--remove-uids=*|--uid-pool=*|--vg-name=*|-d|-h'
    if _ganeti_checkopt '--backend-parameters=*|--candidate-pool-size=*|--enabled-hypervisors=*|--hypervisor-parameters=*|--nic-parameters=*|--vg-name=*|--uid-pool=*|--add-uids=*|--remove-uids=*' '--backend-parameters|-B|--candidate-pool-size|-C|--enabled-hypervisors|--hypervisor-parameters|-H|--nic-parameters|-N|--vg-name|-g|--uid-pool|--add-uids|--remove-uids'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--maintain-node-health=*' --maintain-node-health; then
      _ganeti_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--add-uids --backend-parameters --candidate-pool-size --debug --enabled-hypervisors --help --hypervisor-parameters --maintain-node-health --nic-parameters --no-lvm-storage --remove-uids --uid-pool --vg-name -B -C -H -N -d -g -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgUnknown min=0 max=None>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  queue)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgChoice min=1 max=1 choices=['drain', 'undrain', 'info']>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'drain undrain info'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  init)
    _ganeti_find_first_arg 2 '--backend-parameters|--candidate-pool-size|--enabled-hypervisors|--file-storage-dir|--hypervisor-parameters|--mac-prefix|--maintain-node-health|--master-netdev|--nic-parameters|--secondary-ip|--uid-pool|--vg-name|-B|-C|-H|-N|-g|-m|-s' '--backend-parameters=*|--candidate-pool-size=*|--debug|--enabled-hypervisors=*|--file-storage-dir=*|--help|--hypervisor-parameters=*|--mac-prefix=*|--maintain-node-health=*|--master-netdev=*|--nic-parameters=*|--no-etc-hosts|--no-lvm-storage|--no-ssh-init|--secondary-ip=*|--uid-pool=*|--vg-name=*|-d|-h'
    if _ganeti_checkopt '--backend-parameters=*|--candidate-pool-size=*|--enabled-hypervisors=*|--file-storage-dir=*|--hypervisor-parameters=*|--mac-prefix=*|--master-netdev=*|--nic-parameters=*|--secondary-ip=*|--vg-name=*|--uid-pool=*' '--backend-parameters|-B|--candidate-pool-size|-C|--enabled-hypervisors|--file-storage-dir|--hypervisor-parameters|-H|--mac-prefix|-m|--master-netdev|--nic-parameters|-N|--secondary-ip|-s|--vg-name|-g|--uid-pool'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--maintain-node-health=*' --maintain-node-health; then
      _ganeti_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --candidate-pool-size --debug --enabled-hypervisors --file-storage-dir --help --hypervisor-parameters --mac-prefix --maintain-node-health --master-netdev --nic-parameters --no-etc-hosts --no-lvm-storage --no-ssh-init --secondary-ip --uid-pool --vg-name -B -C -H -N -d -g -h -m -s'
    # 0: <ArgHost min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  version)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  command)
    _ganeti_find_first_arg 2 '--node|-n' '--debug|--help|--node=*|-d|-h'
    if _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --node -d -h -n'
    # 0: <ArgCommand min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      compgenargs=-c
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgUnknown min=0 max=None>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  redist-conf)
    _ganeti_find_first_arg 2 '' '--debug|--help|--submit|-d|-h'
    _ganeti_list_options '--debug --help --submit -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  destroy)
    _ganeti_find_first_arg 2 '' '--debug|--help|--yes-do-it|-d|-h'
    _ganeti_list_options '--debug --help --yes-do-it -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  masterfailover)
    _ganeti_find_first_arg 2 '' '--debug|--help|--no-voting|-d|-h'
    _ganeti_list_options '--debug --help --no-voting -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  watcher)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgChoice min=1 max=1 choices=['pause', 'continue', 'info']>
    # 1: <ArgSuggest min=0 max=1 choices=['30m', '1h', '4h']>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'pause continue info'
    elif [[ "$arg_idx" -ge 1 && "$arg_idx" -lt 2 ]]; then
      choices="$choices "'30m 1h 4h'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  renew-crypto)
    _ganeti_find_first_arg 2 --rapi-certificate '--debug|--force|--help|--new-cluster-certificate|--new-confd-hmac-key|--new-rapi-certificate|--rapi-certificate=*|-d|-f|-h'
    if _ganeti_checkopt '--rapi-certificate=*' --rapi-certificate; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --new-cluster-certificate --new-confd-hmac-key --new-rapi-certificate --rapi-certificate -d -f -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_cluster -o filenames gnt-cluster
_gnt_debug() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'allocator delay submit-job' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  delay)
    _ganeti_find_first_arg 2 -n '--debug|--help|--no-master|-d|-h'
    if _ganeti_checkopt '' -n; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-master -d -h -n'
    # 0: <ArgUnknown min=1 max=1>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  submit-job)
    _ganeti_find_first_arg 2 '--job-repeat|--op-repeat' '--debug|--help|--job-repeat=*|--op-repeat=*|--timing-stats|--verbose|-d|-h|-v'
    if _ganeti_checkopt '--op-repeat=*|--job-repeat=*' '--op-repeat|--job-repeat'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --job-repeat --op-repeat --timing-stats --verbose -d -h -v'
    # 0: <ArgFile min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      compgenargs=-f
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  allocator)
    _ganeti_find_first_arg 2 '--dir|--disk-template|--disks|--iallocator|--mem|--mode|--nics|--os-type|--tags|--vcpus|-I|-m|-o|-p|-t' '--debug|--dir=*|--disk-template=*|--disks=*|--help|--iallocator=*|--mem=*|--mode=*|--nics=*|--os-type=*|--tags=*|--vcpus=*|-d|-h'
    if _ganeti_checkopt '--mem=*|--disks=*|--nics=*|--vcpus=*|--tags=*' '--mem|--disks|--nics|--vcpus|-p|--tags'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--os-type=*' '--os-type|-o'; then
      _ganeti_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--disk-template=*' '--disk-template|-t'; then
      _ganeti_compgen -W 'diskless drbd file plain' -- "$optcur"
      return
    elif _ganeti_checkopt '--mode=*' '--mode|-m'; then
      _ganeti_compgen -W 'allocate multi-evacuate relocate' -- "$optcur"
      return
    elif _ganeti_checkopt '--dir=*' --dir; then
      _ganeti_compgen -W 'in out' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dir --disk-template --disks --help --iallocator --mem --mode --nics --os-type --tags --vcpus -I -d -h -m -o -p -t'
    # 0: <ArgUnknown min=1 max=None>
    compgenargs=
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_debug -o filenames gnt-debug
_gnt_instance() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'activate-disks activate_block_devs add add-tags batch-create console deactivate-disks failover grow-disk info list list-tags migrate modify move reboot recreate-disks reinstall remove remove-tags rename replace-disks replace_disks shutdown start startup stop' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  rename)
    _ganeti_find_first_arg 2 '' '--debug|--help|--no-ip-check|--submit|-d|-h'
    _ganeti_list_options '--debug --help --no-ip-check --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    # 1: <ArgHost min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    elif [[ "$arg_idx" == 1 ]]; then
      compgenargs='-A hostname'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  activate_block_devs)
    _ganeti_find_first_arg 2 '' '--debug|--help|--ignore-size|--submit|-d|-h'
    _ganeti_list_options '--debug --help --ignore-size --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  migrate)
    _ganeti_find_first_arg 2 '' '--cleanup|--debug|--force|--help|--non-live|-d|-f|-h'
    _ganeti_list_options '--cleanup --debug --force --help --non-live -d -f -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--backend-parameters|--disk|--disk-template|--hypervisor-parameters|--net|--node|--os-type|-B|-H|-n|-o|-t' '--backend-parameters=*|--debug|--disk-template=*|--disk=*|--force|--force-variant|--help|--hypervisor-parameters=*|--net=*|--node=*|--os-type=*|--submit|-d|-f|-h'
    if _ganeti_checkopt '--backend-parameters=*|--disk=*|--hypervisor-parameters=*|--net=*' '--backend-parameters|-B|--disk|--hypervisor-parameters|-H|--net'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _ganeti_checkopt '--disk-template=*' '--disk-template|-t'; then
      _ganeti_compgen -W 'diskless drbd file plain' -- "$optcur"
      return
    elif _ganeti_checkopt '--os-type=*' '--os-type|-o'; then
      _ganeti_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --debug --disk --disk-template --force --force-variant --help --hypervisor-parameters --net --node --os-type --submit -B -H -d -f -h -n -o -t'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  replace_disks)
    _ganeti_find_first_arg 2 '--disks|--iallocator|--new-secondary|-I|-n' '--auto|--debug|--disks=*|--early-release|--help|--iallocator=*|--new-secondary=*|--on-primary|--on-secondary|--submit|-a|-d|-h|-p|-s'
    if _ganeti_checkopt '--disks=*' --disks; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--new-secondary=*' '--new-secondary|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto --debug --disks --early-release --help --iallocator --new-secondary --on-primary --on-secondary --submit -I -a -d -h -n -p -s'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  move)
    _ganeti_find_first_arg 2 '--node|--shutdown-timeout|-n' '--debug|--force|--help|--node=*|--shutdown-timeout=*|--submit|-d|-f|-h'
    if _ganeti_checkopt '--shutdown-timeout=*' --shutdown-timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--node=*' '--node|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --node --shutdown-timeout --submit -d -f -h -n'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  startup)
    _ganeti_find_first_arg 2 '--backend-parameters|--hypervisor-parameters|-B|-H' '--all|--backend-parameters=*|--debug|--force|--force-multiple|--help|--hypervisor-parameters=*|--instance|--node|--node-tags|--pri-node-tags|--primary|--sec-node-tags|--secondary|--submit|--tags|-d|-f|-h'
    if _ganeti_checkopt '--hypervisor-parameters=*|--backend-parameters=*' '--hypervisor-parameters|-H|--backend-parameters|-B'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --backend-parameters --debug --force --force-multiple --help --hypervisor-parameters --instance --node --node-tags --pri-node-tags --primary --sec-node-tags --secondary --submit --tags -B -H -d -f -h'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgInstance min=1 max=1>
    # 1: <ArgUnknown min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  stop)
    _ganeti_find_first_arg 2 --timeout '--all|--debug|--force-multiple|--help|--instance|--node|--node-tags|--pri-node-tags|--primary|--sec-node-tags|--secondary|--submit|--tags|--timeout=*|-d|-h'
    if _ganeti_checkopt '--timeout=*' --timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --force-multiple --help --instance --node --node-tags --pri-node-tags --primary --sec-node-tags --secondary --submit --tags --timeout -d -h'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  shutdown)
    _ganeti_find_first_arg 2 --timeout '--all|--debug|--force-multiple|--help|--instance|--node|--node-tags|--pri-node-tags|--primary|--sec-node-tags|--secondary|--submit|--tags|--timeout=*|-d|-h'
    if _ganeti_checkopt '--timeout=*' --timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --force-multiple --help --instance --node --node-tags --pri-node-tags --primary --sec-node-tags --secondary --submit --tags --timeout -d -h'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  activate-disks)
    _ganeti_find_first_arg 2 '' '--debug|--help|--ignore-size|--submit|-d|-h'
    _ganeti_list_options '--debug --help --ignore-size --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  deactivate-disks)
    _ganeti_find_first_arg 2 '' '--debug|--help|--submit|-d|-h'
    _ganeti_list_options '--debug --help --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  recreate-disks)
    _ganeti_find_first_arg 2 --disks '--debug|--disks=*|--help|--submit|-d|-h'
    if _ganeti_checkopt '--disks=*' --disks; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --disks --help --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  reinstall)
    _ganeti_find_first_arg 2 '--os-type|-o' '--all|--debug|--force|--force-multiple|--force-variant|--help|--instance|--node|--node-tags|--os-type=*|--pri-node-tags|--primary|--sec-node-tags|--secondary|--select-os|--submit|--tags|-d|-f|-h'
    if _ganeti_checkopt '--os-type=*' '--os-type|-o'; then
      _ganeti_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --force --force-multiple --force-variant --help --instance --node --node-tags --os-type --pri-node-tags --primary --sec-node-tags --secondary --select-os --submit --tags -d -f -h -o'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 '' '--all|--debug|--help|--roman|--static|-d|-h|-s'
    _ganeti_list_options '--all --debug --help --roman --static -d -h -s'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  batch-create)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgFile min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs=-f
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  console)
    _ganeti_find_first_arg 2 '' '--debug|--help|--show-cmd|-d|-h'
    _ganeti_list_options '--debug --help --show-cmd -d -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgInstance min=1 max=1>
    # 1: <ArgUnknown min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  failover)
    _ganeti_find_first_arg 2 --shutdown-timeout '--debug|--force|--help|--ignore-consistency|--shutdown-timeout=*|--submit|-d|-f|-h'
    if _ganeti_checkopt '--shutdown-timeout=*' --shutdown-timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --ignore-consistency --shutdown-timeout --submit -d -f -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--separator|--units|-o' '--debug|--help|--no-headers|--output=*|--roman|--separator=*|--sync|--units=*|-d|-h'
    if _ganeti_checkopt '--separator=*|--output=*' '--separator|--output|-o'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--units=*' --units; then
      _ganeti_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --roman --separator --sync --units -d -h -o'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  reboot)
    _ganeti_find_first_arg 2 '--shutdown-timeout|--type|-t' '--all|--debug|--force-multiple|--help|--ignore-secondaries|--instance|--node|--node-tags|--pri-node-tags|--primary|--sec-node-tags|--secondary|--shutdown-timeout=*|--submit|--tags|--type=*|-d|-h'
    if _ganeti_checkopt '--type=*' '--type|-t'; then
      _ganeti_compgen -W 'full hard soft' -- "$optcur"
      return
    elif _ganeti_checkopt '--shutdown-timeout=*' --shutdown-timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --force-multiple --help --ignore-secondaries --instance --node --node-tags --pri-node-tags --primary --sec-node-tags --secondary --shutdown-timeout --submit --tags --type -d -h -t'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 --shutdown-timeout '--debug|--force|--help|--ignore-failures|--shutdown-timeout=*|--submit|-d|-f|-h'
    if _ganeti_checkopt '--shutdown-timeout=*' --shutdown-timeout; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --ignore-failures --shutdown-timeout --submit -d -f -h'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  replace-disks)
    _ganeti_find_first_arg 2 '--disks|--iallocator|--new-secondary|-I|-n' '--auto|--debug|--disks=*|--early-release|--help|--iallocator=*|--new-secondary=*|--on-primary|--on-secondary|--submit|-a|-d|-h|-p|-s'
    if _ganeti_checkopt '--disks=*' --disks; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--new-secondary=*' '--new-secondary|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto --debug --disks --early-release --help --iallocator --new-secondary --on-primary --on-secondary --submit -I -a -d -h -n -p -s'
    # 0: <ArgInstance min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  start)
    _ganeti_find_first_arg 2 '--backend-parameters|--hypervisor-parameters|-B|-H' '--all|--backend-parameters=*|--debug|--force|--force-multiple|--help|--hypervisor-parameters=*|--instance|--node|--node-tags|--pri-node-tags|--primary|--sec-node-tags|--secondary|--submit|--tags|-d|-f|-h'
    if _ganeti_checkopt '--hypervisor-parameters=*|--backend-parameters=*' '--hypervisor-parameters|-H|--backend-parameters|-B'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --backend-parameters --debug --force --force-multiple --help --hypervisor-parameters --instance --node --node-tags --pri-node-tags --primary --sec-node-tags --secondary --submit --tags -B -H -d -f -h'
    # 0: <ArgInstance min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add)
    _ganeti_find_first_arg 2 '--backend-parameters|--disk|--disk-template|--file-driver|--file-storage-dir|--hypervisor-parameters|--iallocator|--net|--node|--os-size|--os-type|-B|-H|-I|-n|-o|-s|-t' '--backend-parameters=*|--debug|--disk-template=*|--disk=*|--file-driver=*|--file-storage-dir=*|--force-variant|--help|--hypervisor-parameters=*|--iallocator=*|--net=*|--no-install|--no-ip-check|--no-name-check|--no-nics|--no-start|--no-wait-for-sync|--node=*|--os-size=*|--os-type=*|--submit|-d|-h'
    if _ganeti_checkopt '--backend-parameters=*|--disk=*|--file-storage-dir=*|--hypervisor-parameters=*|--net=*|--os-size=*' '--backend-parameters|-B|--disk|--file-storage-dir|--hypervisor-parameters|-H|--net|--os-size|-s'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--file-driver=*' --file-driver; then
      _ganeti_compgen -W 'blktap loop' -- "$optcur"
      return
    elif _ganeti_checkopt '--os-type=*' '--os-type|-o'; then
      _ganeti_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--node=*' '--node|-n'; then
      local tmp= node1= pfx= curvalue="${optcur#*:}"
      if [[ "$optcur" == *:* ]]; then
        node1="${optcur%%:*}"
        if [[ "$COMP_WORDBREAKS" != *:* ]]; then
          pfx="$node1:"
        fi
      fi
      _ganeti_dbglog pfx="'$pfx'" curvalue="'$curvalue'" node1="'$node1'"
      for i in $(_ganeti_nodes); do
        if [[ -z "$node1" ]]; then
          tmp="$tmp $i $i:"
        elif [[ "$i" != "$node1" ]]; then
          tmp="$tmp $i"
        fi
      done
      _ganeti_compgen -P "$pfx" -W "$tmp" -- "$curvalue"
      return
    elif _ganeti_checkopt '--disk-template=*' '--disk-template|-t'; then
      _ganeti_compgen -W 'diskless drbd file plain' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --debug --disk --disk-template --file-driver --file-storage-dir --force-variant --help --hypervisor-parameters --iallocator --net --no-install --no-ip-check --no-name-check --no-nics --no-start --no-wait-for-sync --node --os-size --os-type --submit -B -H -I -d -h -n -o -s -t'
    # 0: <ArgHost min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  grow-disk)
    _ganeti_find_first_arg 2 '' '--debug|--help|--no-wait-for-sync|--submit|-d|-h'
    _ganeti_list_options '--debug --help --no-wait-for-sync --submit -d -h'
    # 0: <ArgInstance min=1 max=1>
    # 1: <ArgUnknown min=1 max=1>
    # 2: <ArgUnknown min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_instance -o filenames gnt-instance
_gnt_job() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'archive autoarchive cancel info list watch' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  info)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgJobId min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--separator|-o' '--debug|--help|--no-headers|--output=*|--separator=*|-d|-h'
    if _ganeti_checkopt '--separator=*|--output=*' '--separator|--output|-o'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --separator -d -h -o'
    # 0: <ArgJobId min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  watch)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgJobId min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  autoarchive)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgSuggest min=1 max=1 choices=['1d', '1w', '4w']>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'1d 1w 4w'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  cancel)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgJobId min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  archive)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgJobId min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_job -o filenames gnt-job
_gnt_node() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'add add-tags evacuate failover info list list-storage list-tags migrate modify modify-storage powercycle remove remove-tags repair-storage volumes' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  info)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgNode min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-storage)
    _ganeti_find_first_arg 2 '--output|--separator|--storage-type|--units|-o|-t' '--debug|--help|--no-headers|--output=*|--separator=*|--storage-type=*|--units=*|-d|-h'
    if _ganeti_checkopt '--separator=*|--output=*' '--separator|--output|-o'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--units=*' --units; then
      _ganeti_compgen -W 'g h m t' -- "$optcur"
      return
    elif _ganeti_checkopt '--storage-type=*' '--storage-type|-t'; then
      _ganeti_compgen -W 'file lvm-pv lvm-vg' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --separator --storage-type --units -d -h -o -t'
    # 0: <ArgNode min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  powercycle)
    _ganeti_find_first_arg 2 '' '--debug|--force|--help|--yes|-d|-f|-h'
    _ganeti_list_options '--debug --force --help --yes -d -f -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  migrate)
    _ganeti_find_first_arg 2 '' '--debug|--force|--help|--non-live|-d|-f|-h'
    _ganeti_list_options '--debug --force --help --non-live -d -f -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--drained|--master-candidate|--offline|-C|-D|-O' '--auto-promote|--debug|--drained=*|--force|--help|--master-candidate=*|--offline=*|--submit|-d|-f|-h'
    if _ganeti_checkopt '--master-candidate=*|--drained=*|--offline=*' '--master-candidate|-C|--drained|-D|--offline|-O'; then
      _ganeti_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto-promote --debug --drained --force --help --master-candidate --offline --submit -C -D -O -d -f -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  failover)
    _ganeti_find_first_arg 2 '' '--debug|--force|--help|--ignore-consistency|-d|-f|-h'
    _ganeti_list_options '--debug --force --help --ignore-consistency -d -f -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--separator|--units|-o' '--debug|--help|--no-headers|--output=*|--roman|--separator=*|--sync|--units=*|-d|-h'
    if _ganeti_checkopt '--separator=*|--output=*' '--separator|--output|-o'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--units=*' --units; then
      _ganeti_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --roman --separator --sync --units -d -h -o'
    # 0: <ArgNode min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  repair-storage)
    _ganeti_find_first_arg 2 '' '--debug|--help|--ignore-consistency|-d|-h'
    _ganeti_list_options '--debug --help --ignore-consistency -d -h'
    # 0: <ArgNode min=1 max=1>
    # 1: <ArgChoice min=1 max=1 choices=['lvm-vg']>
    # 2: <ArgFile min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    elif [[ "$arg_idx" == 1 ]]; then
      choices="$choices "lvm-vg
    elif [[ "$arg_idx" == 2 ]]; then
      compgenargs=-f
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  evacuate)
    _ganeti_find_first_arg 2 '--iallocator|--new-secondary|-I|-n' '--debug|--early-release|--force|--help|--iallocator=*|--new-secondary=*|-d|-f|-h'
    if _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
      _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _ganeti_checkopt '--new-secondary=*' '--new-secondary|-n'; then
      _ganeti_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --early-release --force --help --iallocator --new-secondary -I -d -f -h -n'
    # 0: <ArgNode min=1 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify-storage)
    _ganeti_find_first_arg 2 --allocatable '--allocatable=*|--debug|--help|-d|-h'
    if _ganeti_checkopt '--allocatable=*' --allocatable; then
      _ganeti_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--allocatable --debug --help -d -h'
    # 0: <ArgNode min=1 max=1>
    # 1: <ArgChoice min=1 max=1 choices=['lvm-pv']>
    # 2: <ArgFile min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    elif [[ "$arg_idx" == 1 ]]; then
      choices="$choices "lvm-pv
    elif [[ "$arg_idx" == 2 ]]; then
      compgenargs=-f
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add)
    _ganeti_find_first_arg 2 '--secondary-ip|-s' '--debug|--help|--no-ssh-key-check|--readd|--secondary-ip=*|-d|-h'
    if _ganeti_checkopt '--secondary-ip=*' '--secondary-ip|-s'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-ssh-key-check --readd --secondary-ip -d -h -s'
    # 0: <ArgHost min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgNode min=1 max=1>
    # 1: <ArgUnknown min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    # 0: <ArgNode min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  volumes)
    _ganeti_find_first_arg 2 '--output|--separator|--units|-o' '--debug|--help|--no-headers|--output=*|--separator=*|--units=*|-d|-h'
    if _ganeti_checkopt '--separator=*|--output=*' '--separator|--output|-o'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    elif _ganeti_checkopt '--units=*' --units; then
      _ganeti_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --separator --units -d -h -o'
    # 0: <ArgNode min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 --from '--debug|--from=*|--help|-d|-h'
    if _ganeti_checkopt '--from=*' --from; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help -d -h'
    # 0: <ArgNode min=1 max=1>
    # 1: <ArgUnknown min=0 max=None>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_node -o filenames gnt-node
_gnt_os() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _ganeti_compgen -W 'diagnose list modify' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  diagnose)
    _ganeti_find_first_arg 2 '' '--debug|--help|-d|-h'
    _ganeti_list_options '--debug --help -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--hypervisor-parameters|-H' '--debug|--help|--hypervisor-parameters=*|-d|-h'
    if _ganeti_checkopt '--hypervisor-parameters=*' '--hypervisor-parameters|-H'; then
      _ganeti_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --hypervisor-parameters -H -d -h'
    # 0: <ArgOs min=1 max=1>
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_os)
    fi
    _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '' '--debug|--help|--no-headers|-d|-h'
    _ganeti_list_options '--debug --help --no-headers -d -h'
    _ganeti_compgen -W "$choices" -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_os -o filenames gnt-os
_ganeti_burnin() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _ganeti_dbglog cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _ganeti_dbglog "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--disk-growth|--disk-size|--disk-template|--hypervisor-parameters|--iallocator|--mem-size|--net-timeout|--nodes|--os|--reboot-types|--rename|-H|-I|-n|-o|-t' '--debug|--disk-growth=*|--disk-size=*|--disk-template=*|--early-release|--http-check|--hypervisor-parameters=*|--iallocator=*|--keep-instances|--mem-size=*|--net-timeout=*|--no-activate-disks|--no-add-disks|--no-add-nics|--no-confd|--no-failover|--no-importexport|--no-ip-check|--no-migrate|--no-move|--no-name-check|--no-nics|--no-reboot|--no-reinstall|--no-replace1|--no-replace2|--no-startstop|--nodes=*|--os=*|--parallel|--reboot-types=*|--rename=*|--verbose|-C|-K|-d|-p|-v'
  if _ganeti_checkopt '--hypervisor-parameters=*|--disk-growth=*|--reboot-types=*|--rename=*' '--hypervisor-parameters|-H|--disk-growth|--reboot-types|--rename'; then
    _ganeti_compgen -W '' -- "$optcur"
    return
  elif _ganeti_checkopt '--nodes=*' '--nodes|-n'; then
    _ganeti_compgen -W '' -- "$optcur"
    return
  elif _ganeti_checkopt '--disk-size=*' --disk-size; then
    _ganeti_compgen -W '10G 128M 1G 1G,256M 4G 4G,1G,1G 512M' -- "$optcur"
    return
  elif _ganeti_checkopt '--os=*' '--os|-o'; then
    _ganeti_compgen -W "$(_ganeti_os)" -- "$optcur"
    return
  elif _ganeti_checkopt '--iallocator=*' '--iallocator|-I'; then
    _ganeti_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
    return
  elif _ganeti_checkopt '--mem-size=*' --mem-size; then
    _ganeti_compgen -W '128M 12G 16G 1G 256M 4G 512M 8G' -- "$optcur"
    return
  elif _ganeti_checkopt '--net-timeout=*' --net-timeout; then
    _ganeti_compgen -W '15 300 60 900' -- "$optcur"
    return
  elif _ganeti_checkopt '--disk-template=*' '--disk-template|-t'; then
    _ganeti_compgen -W 'diskless drbd file plain' -- "$optcur"
    return
  fi
  _ganeti_list_options '--debug --disk-growth --disk-size --disk-template --early-release --http-check --hypervisor-parameters --iallocator --keep-instances --mem-size --net-timeout --no-activate-disks --no-add-disks --no-add-nics --no-confd --no-failover --no-importexport --no-ip-check --no-migrate --no-move --no-name-check --no-nics --no-reboot --no-reinstall --no-replace1 --no-replace2 --no-startstop --nodes --os --parallel --reboot-types --rename --verbose -C -H -I -K -d -n -o -p -t -v'
  # 0: <ArgInstance min=1 max=None>
  compgenargs=
  if [[ "$arg_idx" -ge 0 ]]; then
    choices="$choices "$(_ganeti_instances)
  fi
  _ganeti_compgen -W "$choices" $compgenargs -- "$cur"
  return
}
complete -F _ganeti_burnin -o filenames /usr/lib/ganeti/tools/burnin

