gnt_shopt_extglob=$(shopt -p extglob || :)
shopt -s extglob
# This script is automatically generated at build time.
# Do not modify manually.
_gnt_log() {
  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 /usr/share/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/lib/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/lib64/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/local/lib/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/local/lib64/ganeti/os 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /srv/ganeti/os 2>/dev/null && echo * || : )
}
_ganeti_iallocator() {
  ( shopt -s nullglob && cd /usr/lib/ganeti/iallocators 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/lib64/ganeti/iallocators 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/local/lib/ganeti/iallocators 2>/dev/null && echo * || : )
  ( shopt -s nullglob && cd /usr/local/lib64/ganeti/iallocators 2>/dev/null && echo * || : )
}
_ganeti_nodegroup() {
  cat /var/lib/ganeti/ssconf_nodegroups 2>/dev/null || :
}
_ganeti_network() {
  cat /var/lib/ganeti/ssconf_networks 2>/dev/null || :
}
_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=
}
_gnt_checkopt() {
  if [[ -n "$1" && "$cur" == @($1) ]]; then
    optcur="${cur#--*=}"
    return 0
  elif [[ -n "$2" && "$prev" == @($2) ]]; then
    optcur="$cur"
    return 0
  fi
  _gnt_log optcur="'$optcur'"
  return 1
}
_gnt_compgen() {
  COMPREPLY=( $(compgen "$@") )
  _gnt_log 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
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'export import list list-fields remove' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  export)
    _ganeti_find_first_arg 2 '--node|--priority|--reason|--shutdown-timeout|--transport-compression|--zeroing-timeout-fixed|--zeroing-timeout-per-mib|-n' '--debug|--dry-run|--force|--help|--ignore-remove-failures|--long-sleep|--node=*|--noshutdown|--print-jobid|--priority=*|--reason=*|--remove-instance|--shutdown-timeout=*|--submit|--transport-compression=*|--zero-free-space|--zeroing-timeout-fixed=*|--zeroing-timeout-per-mib=*|-d|-f|-h'
    if _gnt_checkopt '--node=*' '--node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--transport-compression=*|--shutdown-timeout=*|--zeroing-timeout-fixed=*|--zeroing-timeout-per-mib=*|--reason=*' '--transport-compression|--shutdown-timeout|--zeroing-timeout-fixed|--zeroing-timeout-per-mib|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --ignore-remove-failures --long-sleep --node --noshutdown --print-jobid --priority --reason --remove-instance --shutdown-timeout --submit --transport-compression --zero-free-space --zeroing-timeout-fixed --zeroing-timeout-per-mib -d -f -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  import)
    _ganeti_find_first_arg 2 '--backend-parameters|--compress|--disk|--disk-template|--file-driver|--file-storage-dir|--helper-shutdown-timeout|--helper-startup-timeout|--hypervisor-parameters|--iallocator|--net|--node|--node-group|--os-parameters|--os-parameters-private|--os-parameters-secret|--os-size|--priority|--reason|--src-dir|--src-node|--tags|-B|-H|-I|-O|-g|-n|-s|-t' '--backend-parameters=*|--compress=*|--debug|--disk-template=*|--disk=*|--dry-run|--file-driver=*|--file-storage-dir=*|--help|--helper-shutdown-timeout=*|--helper-startup-timeout=*|--hypervisor-parameters=*|--iallocator=*|--identify-defaults|--ignore-ipolicy|--ip-check|--name-check|--net=*|--no-conflicts-check|--no-ip-check|--no-name-check|--no-nics|--no-wait-for-sync|--node-group=*|--node=*|--opportunistic-locking|--os-parameters-private=*|--os-parameters-secret=*|--os-parameters=*|--os-size=*|--print-jobid|--priority=*|--reason=*|--src-dir=*|--src-node=*|--submit|--tags=*|-d|-h'
    if _gnt_checkopt '--backend-parameters=*|--disk=*|--file-storage-dir=*|--hypervisor-parameters=*|--net=*|--os-parameters=*|--os-parameters-private=*|--os-parameters-secret=*|--os-size=*|--tags=*|--src-dir=*|--compress=*|--helper-startup-timeout=*|--helper-shutdown-timeout=*|--reason=*' '--backend-parameters|-B|--disk|--file-storage-dir|--hypervisor-parameters|-H|--net|--os-parameters|-O|--os-parameters-private|--os-parameters-secret|--os-size|-s|--tags|--src-dir|--compress|--helper-startup-timeout|--helper-shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--disk-template=*' '--disk-template|-t'; then
      _gnt_compgen -W 'blockdev diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
      return
    elif _gnt_checkopt '--file-driver=*' --file-driver; then
      _gnt_compgen -W 'blktap blktap2 loop' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--node=*' '--node|-n'; then
      local tmp= node1= pfx= curvalue="${optcur#*:}"
      if [[ "$optcur" == *:* ]]; then
        node1="${optcur%%:*}"
        if [[ "$COMP_WORDBREAKS" != *:* ]]; then
          pfx="$node1:"
        fi
      fi
      _gnt_log 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
      _gnt_compgen -P "$pfx" -W "$tmp" -- "$curvalue"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--src-node=*' --src-node; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --compress --debug --disk --disk-template --dry-run --file-driver --file-storage-dir --help --helper-shutdown-timeout --helper-startup-timeout --hypervisor-parameters --iallocator --identify-defaults --ignore-ipolicy --ip-check --name-check --net --no-conflicts-check --no-ip-check --no-name-check --no-nics --no-wait-for-sync --node --node-group --opportunistic-locking --os-parameters --os-parameters-private --os-parameters-secret --os-size --print-jobid --priority --reason --src-dir --src-node --submit --tags -B -H -I -O -d -g -h -n -s -t'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--node|--output|--reason|--separator|--units|-n|-o' '--debug|--help|--no-headers|--node=*|--output=*|--reason=*|--separator=*|--units=*|--verbose|-d|-h|-v'
    if _gnt_checkopt '--node=*' '--node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--units=*' --units; then
      _gnt_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --node --output --reason --separator --units --verbose -d -h -n -o -v'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    _gnt_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
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'activate-master-ip add-tags command copyfile deactivate-master-ip destroy epo getmaster info init list-tags master-failover master-ping masterfailover modify queue redist-conf remove-tags rename renew-crypto repair-disk-sizes search-tags show show-ispecs-cmd upgrade verify verify-disks version watcher' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  activate-master-ip|getmaster|list-tags|master-ping|show-ispecs-cmd|version)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  command)
    _ganeti_find_first_arg 2 '--node|--node-group|--reason|-g|-n' '--debug|--failure-only|--help|--node-group=*|--node=*|--reason=*|--show-machine-names|-M|-d|-h'
    if _gnt_checkopt '--node=*' '--node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --failure-only --help --node --node-group --reason --show-machine-names -M -d -g -h -n'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      compgenargs=-c
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  copyfile)
    _ganeti_find_first_arg 2 '--node|--node-group|--reason|-g|-n' '--debug|--help|--node-group=*|--node=*|--reason=*|--use-replication-network|-d|-h'
    if _gnt_checkopt '--node=*' '--node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --node --node-group --reason --use-replication-network -d -g -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  deactivate-master-ip)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|--yes|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason --yes -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  destroy)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|--ya-rly|--yes-do-it|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason --ya-rly --yes-do-it -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  epo)
    _ganeti_find_first_arg 2 '--oob-timeout|--power-delay|--reason|--shutdown-timeout' '--all|--debug|--force|--groups|--help|--on|--oob-timeout=*|--power-delay=*|--reason=*|--shutdown-timeout=*|-d|-f|-h'
    if _gnt_checkopt '--oob-timeout=*|--shutdown-timeout=*|--power-delay=*|--reason=*' '--oob-timeout|--shutdown-timeout|--power-delay|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --force --groups --help --on --oob-timeout --power-delay --reason --shutdown-timeout -d -f -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info|show)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|--roman|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason --roman -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  init)
    _ganeti_find_first_arg 2 '--backend-parameters|--candidate-pool-size|--compression-tools|--default-iallocator|--default-iallocator-params|--disk-parameters|--disk-state|--drbd-usermode-helper|--enabled-disk-templates|--enabled-hypervisors|--file-storage-dir|--gluster-storage-dir|--hypervisor-parameters|--hypervisor-state|--install-image|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-spindle-ratio|--ipolicy-std-specs|--ipolicy-vcpu-ratio|--mac-prefix|--maintain-node-health|--master-netdev|--master-netmask|--nic-parameters|--node-parameters|--prealloc-wipe-disks|--primary-ip-version|--reason|--secondary-ip|--shared-file-storage-dir|--specs-cpu-count|--specs-disk-count|--specs-disk-size|--specs-mem-size|--specs-nic-count|--ssh-key-bits|--ssh-key-type|--uid-pool|--use-external-mip-script|--user-shutdown|--vg-name|--zeroing-image|-B|-C|-D|-H|-I|-N|-m|-s' '--backend-parameters=*|--candidate-pool-size=*|--compression-tools=*|--debug|--default-iallocator-params=*|--default-iallocator=*|--disk-parameters=*|--disk-state=*|--drbd-usermode-helper=*|--enabled-disk-templates=*|--enabled-hypervisors=*|--file-storage-dir=*|--gluster-storage-dir=*|--help|--hypervisor-parameters=*|--hypervisor-state=*|--install-image=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-spindle-ratio=*|--ipolicy-std-specs=*|--ipolicy-vcpu-ratio=*|--mac-prefix=*|--maintain-node-health=*|--master-netdev=*|--master-netmask=*|--nic-parameters=*|--no-etc-hosts|--no-ssh-init|--node-parameters=*|--prealloc-wipe-disks=*|--primary-ip-version=*|--reason=*|--secondary-ip=*|--shared-file-storage-dir=*|--specs-cpu-count=*|--specs-disk-count=*|--specs-disk-size=*|--specs-mem-size=*|--specs-nic-count=*|--ssh-key-bits=*|--ssh-key-type=*|--uid-pool=*|--use-external-mip-script=*|--user-shutdown=*|--vg-name=*|--zeroing-image=*|-d|-h'
    if _gnt_checkopt '--backend-parameters=*|--candidate-pool-size=*|--enabled-hypervisors=*|--file-storage-dir=*|--hypervisor-parameters=*|--mac-prefix=*|--master-netdev=*|--master-netmask=*|--nic-parameters=*|--secondary-ip=*|--vg-name=*|--uid-pool=*|--drbd-usermode-helper=*|--default-iallocator-params=*|--primary-ip-version=*|--node-parameters=*|--shared-file-storage-dir=*|--disk-parameters=*|--hypervisor-state=*|--disk-state=*|--enabled-disk-templates=*|--ipolicy-std-specs=*|--gluster-storage-dir=*|--install-image=*|--zeroing-image=*|--compression-tools=*|--ssh-key-bits=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-vcpu-ratio=*|--ipolicy-spindle-ratio=*|--specs-cpu-count=*|--specs-disk-count=*|--specs-disk-size=*|--specs-mem-size=*|--specs-nic-count=*|--reason=*' '--backend-parameters|-B|--candidate-pool-size|-C|--enabled-hypervisors|--file-storage-dir|--hypervisor-parameters|-H|--mac-prefix|-m|--master-netdev|--master-netmask|--nic-parameters|-N|--secondary-ip|-s|--vg-name|--uid-pool|--drbd-usermode-helper|--default-iallocator-params|--primary-ip-version|--node-parameters|--shared-file-storage-dir|--disk-parameters|-D|--hypervisor-state|--disk-state|--enabled-disk-templates|--ipolicy-std-specs|--gluster-storage-dir|--install-image|--zeroing-image|--compression-tools|--ssh-key-bits|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-vcpu-ratio|--ipolicy-spindle-ratio|--specs-cpu-count|--specs-disk-count|--specs-disk-size|--specs-mem-size|--specs-nic-count|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--maintain-node-health=*|--prealloc-wipe-disks=*|--use-external-mip-script=*|--user-shutdown=*' '--maintain-node-health|--prealloc-wipe-disks|--use-external-mip-script|--user-shutdown'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    elif _gnt_checkopt '--default-iallocator=*' '--default-iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--ssh-key-type=*' --ssh-key-type; then
      _gnt_compgen -W 'dsa ecdsa rsa' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --candidate-pool-size --compression-tools --debug --default-iallocator --default-iallocator-params --disk-parameters --disk-state --drbd-usermode-helper --enabled-disk-templates --enabled-hypervisors --file-storage-dir --gluster-storage-dir --help --hypervisor-parameters --hypervisor-state --install-image --ipolicy-bounds-specs --ipolicy-disk-templates --ipolicy-spindle-ratio --ipolicy-std-specs --ipolicy-vcpu-ratio --mac-prefix --maintain-node-health --master-netdev --master-netmask --nic-parameters --no-etc-hosts --no-ssh-init --node-parameters --prealloc-wipe-disks --primary-ip-version --reason --secondary-ip --shared-file-storage-dir --specs-cpu-count --specs-disk-count --specs-disk-size --specs-mem-size --specs-nic-count --ssh-key-bits --ssh-key-type --uid-pool --use-external-mip-script --user-shutdown --vg-name --zeroing-image -B -C -D -H -I -N -d -h -m -s'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  master-failover|masterfailover)
    _ganeti_find_first_arg 2 '--ignore-offline-nodes|--reason' '--debug|--help|--ignore-offline-nodes=*|--no-voting|--reason=*|--yes-do-it|-d|-h'
    if _gnt_checkopt '--ignore-offline-nodes=*|--reason=*' '--ignore-offline-nodes|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --ignore-offline-nodes --no-voting --reason --yes-do-it -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--add-uids|--backend-parameters|--candidate-pool-size|--compression-tools|--data-collector-interval|--default-iallocator|--default-iallocator-params|--disk-parameters|--disk-state|--drbd-usermode-helper|--enabled-data-collectors|--enabled-disk-templates|--enabled-hypervisors|--file-storage-dir|--hypervisor-parameters|--hypervisor-state|--install-image|--instance-communication-network|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-spindle-ratio|--ipolicy-std-specs|--ipolicy-vcpu-ratio|--mac-prefix|--maintain-node-health|--master-netdev|--master-netmask|--max-running-jobs|--max-tracked-jobs|--modify-etc-hosts|--nic-parameters|--node-parameters|--prealloc-wipe-disks|--priority|--reason|--remove-uids|--reserved-lvs|--shared-file-storage-dir|--uid-pool|--use-external-mip-script|--user-shutdown|--vg-name|--zeroing-image|-B|-C|-D|-H|-I|-N|-m' '--add-uids=*|--backend-parameters=*|--candidate-pool-size=*|--compression-tools=*|--data-collector-interval=*|--debug|--default-iallocator-params=*|--default-iallocator=*|--disk-parameters=*|--disk-state=*|--drbd-usermode-helper=*|--dry-run|--enabled-data-collectors=*|--enabled-disk-templates=*|--enabled-hypervisors=*|--file-storage-dir=*|--force|--help|--hypervisor-parameters=*|--hypervisor-state=*|--install-image=*|--instance-communication-network=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-spindle-ratio=*|--ipolicy-std-specs=*|--ipolicy-vcpu-ratio=*|--mac-prefix=*|--maintain-node-health=*|--master-netdev=*|--master-netmask=*|--max-running-jobs=*|--max-tracked-jobs=*|--modify-etc-hosts=*|--nic-parameters=*|--node-parameters=*|--prealloc-wipe-disks=*|--print-jobid|--priority=*|--reason=*|--remove-uids=*|--reserved-lvs=*|--shared-file-storage-dir=*|--submit|--uid-pool=*|--use-external-mip-script=*|--user-shutdown=*|--vg-name=*|--zeroing-image=*|-d|-f|-h'
    if _gnt_checkopt '--backend-parameters=*|--candidate-pool-size=*|--max-running-jobs=*|--max-tracked-jobs=*|--install-image=*|--instance-communication-network=*|--enabled-hypervisors=*|--hypervisor-parameters=*|--mac-prefix=*|--master-netdev=*|--master-netmask=*|--nic-parameters=*|--vg-name=*|--uid-pool=*|--add-uids=*|--remove-uids=*|--drbd-usermode-helper=*|--default-iallocator-params=*|--reserved-lvs=*|--node-parameters=*|--disk-parameters=*|--hypervisor-state=*|--disk-state=*|--enabled-disk-templates=*|--ipolicy-std-specs=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-vcpu-ratio=*|--ipolicy-spindle-ratio=*|--file-storage-dir=*|--shared-file-storage-dir=*|--zeroing-image=*|--compression-tools=*|--enabled-data-collectors=*|--data-collector-interval=*|--reason=*' '--backend-parameters|-B|--candidate-pool-size|-C|--max-running-jobs|--max-tracked-jobs|--install-image|--instance-communication-network|--enabled-hypervisors|--hypervisor-parameters|-H|--mac-prefix|-m|--master-netdev|--master-netmask|--nic-parameters|-N|--vg-name|--uid-pool|--add-uids|--remove-uids|--drbd-usermode-helper|--default-iallocator-params|--reserved-lvs|--node-parameters|--disk-parameters|-D|--hypervisor-state|--disk-state|--enabled-disk-templates|--ipolicy-std-specs|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-vcpu-ratio|--ipolicy-spindle-ratio|--file-storage-dir|--shared-file-storage-dir|--zeroing-image|--compression-tools|--enabled-data-collectors|--data-collector-interval|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--maintain-node-health=*|--prealloc-wipe-disks=*|--use-external-mip-script=*|--modify-etc-hosts=*|--user-shutdown=*' '--maintain-node-health|--prealloc-wipe-disks|--use-external-mip-script|--modify-etc-hosts|--user-shutdown'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    elif _gnt_checkopt '--default-iallocator=*' '--default-iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--add-uids --backend-parameters --candidate-pool-size --compression-tools --data-collector-interval --debug --default-iallocator --default-iallocator-params --disk-parameters --disk-state --drbd-usermode-helper --dry-run --enabled-data-collectors --enabled-disk-templates --enabled-hypervisors --file-storage-dir --force --help --hypervisor-parameters --hypervisor-state --install-image --instance-communication-network --ipolicy-bounds-specs --ipolicy-disk-templates --ipolicy-spindle-ratio --ipolicy-std-specs --ipolicy-vcpu-ratio --mac-prefix --maintain-node-health --master-netdev --master-netmask --max-running-jobs --max-tracked-jobs --modify-etc-hosts --nic-parameters --node-parameters --prealloc-wipe-disks --print-jobid --priority --reason --remove-uids --reserved-lvs --shared-file-storage-dir --submit --uid-pool --use-external-mip-script --user-shutdown --vg-name --zeroing-image -B -C -D -H -I -N -d -f -h -m'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  queue)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'drain undrain info'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  redist-conf)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|--yes-do-it|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --print-jobid --priority --reason --submit --yes-do-it -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  rename)
    _ganeti_find_first_arg 2 --reason '--debug|--dry-run|--force|--help|--reason=*|-d|-f|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --reason -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  renew-crypto)
    _ganeti_find_first_arg 2 '--cluster-domain-secret|--rapi-certificate|--reason|--spice-ca-certificate|--spice-certificate|--ssh-key-bits|--ssh-key-type' '--cluster-domain-secret=*|--debug|--force|--help|--new-cluster-certificate|--new-cluster-domain-secret|--new-confd-hmac-key|--new-node-certificates|--new-rapi-certificate|--new-spice-certificate|--new-ssh-keys|--no-ssh-key-check|--rapi-certificate=*|--reason=*|--spice-ca-certificate=*|--spice-certificate=*|--ssh-key-bits=*|--ssh-key-type=*|--verbose|-d|-f|-h|-v'
    if _gnt_checkopt '--rapi-certificate=*|--cluster-domain-secret=*|--spice-certificate=*|--spice-ca-certificate=*|--ssh-key-bits=*|--reason=*' '--rapi-certificate|--cluster-domain-secret|--spice-certificate|--spice-ca-certificate|--ssh-key-bits|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--ssh-key-type=*' --ssh-key-type; then
      _gnt_compgen -W 'dsa ecdsa rsa' -- "$optcur"
      return
    fi
    _ganeti_list_options '--cluster-domain-secret --debug --force --help --new-cluster-certificate --new-cluster-domain-secret --new-confd-hmac-key --new-node-certificates --new-rapi-certificate --new-spice-certificate --new-ssh-keys --no-ssh-key-check --rapi-certificate --reason --spice-ca-certificate --spice-certificate --ssh-key-bits --ssh-key-type --verbose -d -f -h -v'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  repair-disk-sizes)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  search-tags)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  upgrade)
    _ganeti_find_first_arg 2 '--reason|--to' '--debug|--help|--reason=*|--resume|--to=*|-d|-h'
    if _gnt_checkopt '--to=*|--reason=*' '--to|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason --resume --to -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  verify)
    _ganeti_find_first_arg 2 '--ignore-errors|--node-group|--priority|--reason|-I|-g' '--debug|--debug-simulate-errors|--dry-run|--error-codes|--help|--ignore-errors=*|--no-hv-param-assessment|--no-nplus1-mem|--node-group=*|--priority=*|--reason=*|--verbose|--verify-ssh-clutter|-d|-h|-v'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--ignore-errors=*' '--ignore-errors|-I'; then
      _gnt_compgen -W 'ECLUSTERCERT ECLUSTERCFG ECLUSTERCLIENTCERT ECLUSTERDANGLINGINST ECLUSTERDANGLINGNODES ECLUSTERFILECHECK EEXTAGS EGROUPDIFFERENTPVSIZE EINSTANCEBADNODE EINSTANCEDOWN EINSTANCEFAULTYDISK EINSTANCELAYOUT EINSTANCEMISSINGCFGPARAMETER EINSTANCEMISSINGDISK EINSTANCEPOLICY EINSTANCESPLITGROUPS EINSTANCEUNSUITABLENODE EINSTANCEWRONGNODE ENODEDRBD ENODEDRBDHELPER ENODEDRBDVERSION ENODEFILECHECK ENODEFILESTORAGEPATHS ENODEFILESTORAGEPATHUNUSABLE ENODEGLUSTERSTORAGEPATHUNUSABLE ENODEHOOKS ENODEHV ENODELVM ENODEN1 ENODENET ENODEOOBPATH ENODEORPHANINSTANCE ENODEORPHANLV ENODEOS ENODERPC ENODESETUP ENODESHAREDFILESTORAGEPATHUNUSABLE ENODESSH ENODETIME ENODEUSERSCRIPTS ENODEVERSION' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --debug-simulate-errors --dry-run --error-codes --help --ignore-errors --no-hv-param-assessment --no-nplus1-mem --node-group --priority --reason --verbose --verify-ssh-clutter -I -d -g -h -v'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  verify-disks)
    _ganeti_find_first_arg 2 '--node-group|--priority|--reason|-g' '--debug|--help|--no-strict|--node-group=*|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-strict --node-group --priority --reason -d -g -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  watcher)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    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
    _gnt_compgen -W "$choices" $compgenargs -- "$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
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'allocator delay iallocator locks metad submit-job test-jobqueue test-osparams wconfd' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  allocator|iallocator)
    _ganeti_find_first_arg 2 '--count|--dir|--disk-template|--disks|--evac-mode|--iallocator|--memory|--mode|--nics|--os-type|--priority|--reason|--spindle-use|--tags|--target-groups|--vcpus|-I|-m|-o|-p|-t' '--count=*|--debug|--dir=*|--disk-template=*|--disks=*|--dry-run|--evac-mode=*|--help|--iallocator=*|--memory=*|--mode=*|--nics=*|--os-type=*|--priority=*|--reason=*|--spindle-use=*|--tags=*|--target-groups=*|--vcpus=*|-d|-h'
    if _gnt_checkopt '--dir=*' --dir; then
      _gnt_compgen -W 'in out' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--mode=*' '--mode|-m'; then
      _gnt_compgen -W 'allocate allocate-secondary change-group multi-allocate node-evacuate relocate' -- "$optcur"
      return
    elif _gnt_checkopt '--memory=*|--disks=*|--nics=*|--vcpus=*|--tags=*|--target-groups=*|--spindle-use=*|--count=*|--reason=*' '--memory|--disks|--nics|--vcpus|-p|--tags|--target-groups|--spindle-use|--count|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--disk-template=*' '--disk-template|-t'; then
      _gnt_compgen -W 'blockdev diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
      return
    elif _gnt_checkopt '--os-type=*' '--os-type|-o'; then
      _gnt_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _gnt_checkopt '--evac-mode=*' --evac-mode; then
      _gnt_compgen -W 'all primary-only secondary-only' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--count --debug --dir --disk-template --disks --dry-run --evac-mode --help --iallocator --memory --mode --nics --os-type --priority --reason --spindle-use --tags --target-groups --vcpus -I -d -h -m -o -p -t'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  delay)
    _ganeti_find_first_arg 2 '--priority|--reason|--repeat|-n|-r' '--debug|--dry-run|--help|--interruptible|--no-locks|--no-master|--print-jobid|--priority=*|--reason=*|--repeat=*|--submit|-d|-h|-i|-l'
    if _gnt_checkopt '--repeat=*|--reason=*' '-n|--repeat|-r|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --interruptible --no-locks --no-master --print-jobid --priority --reason --repeat --submit -d -h -i -l -n -r'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  locks)
    _ganeti_find_first_arg 2 '--interval|--output|--reason|--separator|-o' '--debug|--help|--interval=*|--no-headers|--output=*|--reason=*|--separator=*|--verbose|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--interval=*|--reason=*' '--separator|--output|-o|--interval|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --interval --no-headers --output --reason --separator --verbose -d -h -o -v'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  metad)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  submit-job)
    _ganeti_find_first_arg 2 '--job-repeat|--op-repeat|--priority|--reason' '--debug|--dry-run|--each|--help|--job-repeat=*|--op-repeat=*|--priority=*|--reason=*|--timing-stats|--verbose|-d|-h|-v'
    if _gnt_checkopt '--op-repeat=*|--job-repeat=*|--reason=*' '--op-repeat|--job-repeat|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --each --help --job-repeat --op-repeat --priority --reason --timing-stats --verbose -d -h -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  test-jobqueue)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  test-osparams)
    _ganeti_find_first_arg 2 '--os-parameters-secret|--reason' '--debug|--help|--os-parameters-secret=*|--print-jobid|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--os-parameters-secret=*|--reason=*' '--os-parameters-secret|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --os-parameters-secret --print-jobid --reason --submit -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  wconfd)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_debug -o filenames gnt-debug
_gnt_group() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'add add-tags assign-nodes evacuate info list list-fields list-tags modify remove remove-tags rename show-ispecs-cmd' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  add)
    _ganeti_find_first_arg 2 '--alloc-policy|--disk-parameters|--disk-state|--hypervisor-state|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-spindle-ratio|--ipolicy-vcpu-ratio|--node-parameters|--priority|--reason|-D' '--alloc-policy=*|--debug|--disk-parameters=*|--disk-state=*|--dry-run|--help|--hypervisor-state=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-spindle-ratio=*|--ipolicy-vcpu-ratio=*|--node-parameters=*|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--alloc-policy=*|--node-parameters=*|--disk-parameters=*|--hypervisor-state=*|--disk-state=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-vcpu-ratio=*|--ipolicy-spindle-ratio=*|--reason=*' '--alloc-policy|--node-parameters|--disk-parameters|-D|--hypervisor-state|--disk-state|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-vcpu-ratio|--ipolicy-spindle-ratio|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--alloc-policy --debug --disk-parameters --disk-state --dry-run --help --hypervisor-state --ipolicy-bounds-specs --ipolicy-disk-templates --ipolicy-spindle-ratio --ipolicy-vcpu-ratio --node-parameters --print-jobid --priority --reason --submit -D -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  assign-nodes)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--force|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --print-jobid --priority --reason --submit -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    elif [[ "$arg_idx" -ge 1 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  evacuate)
    _ganeti_find_first_arg 2 '--iallocator|--reason|--to|-I' '--debug|--early-release|--force-failover|--help|--iallocator=*|--print-jobid|--reason=*|--sequential|--submit|--to=*|-d|-h'
    if _gnt_checkopt '--to=*' --to; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --early-release --force-failover --help --iallocator --print-jobid --reason --sequential --submit --to -I -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|-o' '--debug|--filter|--help|--no-headers|--output=*|--reason=*|--separator=*|--verbose|-F|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --filter --help --no-headers --output --reason --separator --verbose -F -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--alloc-policy|--disk-parameters|--disk-state|--hypervisor-state|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-spindle-ratio|--ipolicy-vcpu-ratio|--node-parameters|--priority|--reason|-D' '--alloc-policy=*|--debug|--disk-parameters=*|--disk-state=*|--dry-run|--help|--hypervisor-state=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-spindle-ratio=*|--ipolicy-vcpu-ratio=*|--node-parameters=*|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--alloc-policy=*|--node-parameters=*|--hypervisor-state=*|--disk-state=*|--disk-parameters=*|--ipolicy-bounds-specs=*|--ipolicy-disk-templates=*|--ipolicy-vcpu-ratio=*|--ipolicy-spindle-ratio=*|--reason=*' '--alloc-policy|--node-parameters|--hypervisor-state|--disk-state|--disk-parameters|-D|--ipolicy-bounds-specs|--ipolicy-disk-templates|--ipolicy-vcpu-ratio|--ipolicy-spindle-ratio|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--alloc-policy --debug --disk-parameters --disk-state --dry-run --help --hypervisor-state --ipolicy-bounds-specs --ipolicy-disk-templates --ipolicy-spindle-ratio --ipolicy-vcpu-ratio --node-parameters --print-jobid --priority --reason --submit -D -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  rename)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 && "$arg_idx" -lt 2 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  show-ispecs-cmd)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--include-defaults|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --include-defaults --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_group -o filenames gnt-group
_gnt_instance() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'activate-disks add add-tags batch-create change-group console deactivate-disks failover grow-disk info list list-fields list-tags migrate modify move reboot recreate-disks reinstall remove remove-tags rename replace-disks show shutdown start startup stop' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  activate-disks)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--ignore-size|--print-jobid|--priority=*|--reason=*|--submit|--wait-for-sync|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --ignore-size --print-jobid --priority --reason --submit --wait-for-sync -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add)
    _ganeti_find_first_arg 2 '--backend-parameters|--communication|--disk|--disk-template|--file-driver|--file-storage-dir|--helper-shutdown-timeout|--helper-startup-timeout|--hypervisor-parameters|--iallocator|--net|--node|--node-group|--os-parameters|--os-parameters-private|--os-parameters-secret|--os-size|--os-type|--priority|--reason|--tags|-B|-H|-I|-O|-c|-g|-n|-o|-s|-t' '--backend-parameters=*|--commit|--communication=*|--debug|--disk-template=*|--disk=*|--dry-run|--file-driver=*|--file-storage-dir=*|--force-variant|--forthcoming|--help|--helper-shutdown-timeout=*|--helper-startup-timeout=*|--hypervisor-parameters=*|--iallocator=*|--ignore-ipolicy|--ip-check|--name-check|--net=*|--no-conflicts-check|--no-install|--no-ip-check|--no-name-check|--no-nics|--no-start|--no-wait-for-sync|--node-group=*|--node=*|--opportunistic-locking|--os-parameters-private=*|--os-parameters-secret=*|--os-parameters=*|--os-size=*|--os-type=*|--print-jobid|--priority=*|--reason=*|--submit|--tags=*|-d|-h'
    if _gnt_checkopt '--backend-parameters=*|--disk=*|--file-storage-dir=*|--hypervisor-parameters=*|--net=*|--os-parameters=*|--os-parameters-private=*|--os-parameters-secret=*|--os-size=*|--tags=*|--helper-startup-timeout=*|--helper-shutdown-timeout=*|--reason=*' '--backend-parameters|-B|--disk|--file-storage-dir|--hypervisor-parameters|-H|--net|--os-parameters|-O|--os-parameters-private|--os-parameters-secret|--os-size|-s|--tags|--helper-startup-timeout|--helper-shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--disk-template=*' '--disk-template|-t'; then
      _gnt_compgen -W 'blockdev diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
      return
    elif _gnt_checkopt '--file-driver=*' --file-driver; then
      _gnt_compgen -W 'blktap blktap2 loop' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--node=*' '--node|-n'; then
      local tmp= node1= pfx= curvalue="${optcur#*:}"
      if [[ "$optcur" == *:* ]]; then
        node1="${optcur%%:*}"
        if [[ "$COMP_WORDBREAKS" != *:* ]]; then
          pfx="$node1:"
        fi
      fi
      _gnt_log 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
      _gnt_compgen -P "$pfx" -W "$tmp" -- "$curvalue"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--os-type=*' '--os-type|-o'; then
      _gnt_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _gnt_checkopt '--communication=*' '--communication|-c'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --commit --communication --debug --disk --disk-template --dry-run --file-driver --file-storage-dir --force-variant --forthcoming --help --helper-shutdown-timeout --helper-startup-timeout --hypervisor-parameters --iallocator --ignore-ipolicy --ip-check --name-check --net --no-conflicts-check --no-install --no-ip-check --no-name-check --no-nics --no-start --no-wait-for-sync --node --node-group --opportunistic-locking --os-parameters --os-parameters-private --os-parameters-secret --os-size --os-type --print-jobid --priority --reason --submit --tags -B -H -I -O -c -d -g -h -n -o -s -t'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  batch-create)
    _ganeti_find_first_arg 2 '--iallocator|--priority|--reason|-I' '--debug|--dry-run|--help|--iallocator=*|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --iallocator --print-jobid --priority --reason --submit -I -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  change-group)
    _ganeti_find_first_arg 2 '--iallocator|--priority|--reason|--to|-I' '--debug|--early-release|--help|--iallocator=*|--print-jobid|--priority=*|--reason=*|--submit|--to=*|-d|-h'
    if _gnt_checkopt '--to=*' --to; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --early-release --help --iallocator --print-jobid --priority --reason --submit --to -I -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  console)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|--show-cmd|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason --show-cmd -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  deactivate-disks)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--force|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --print-jobid --priority --reason --submit -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  failover)
    _ganeti_find_first_arg 2 '--iallocator|--priority|--reason|--shutdown-timeout|--target-node|-I|-n' '--cleanup|--debug|--dry-run|--force|--help|--iallocator=*|--ignore-consistency|--ignore-ipolicy|--print-jobid|--priority=*|--reason=*|--shutdown-timeout=*|--submit|--target-node=*|-d|-f|-h'
    if _gnt_checkopt '--shutdown-timeout=*|--reason=*' '--shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--target-node=*' '--target-node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--cleanup --debug --dry-run --force --help --iallocator --ignore-consistency --ignore-ipolicy --print-jobid --priority --reason --shutdown-timeout --submit --target-node -I -d -f -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  grow-disk)
    _ganeti_find_first_arg 2 '--priority|--reason' '--absolute|--debug|--dry-run|--help|--ignore-ipolicy|--no-wait-for-sync|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--absolute --debug --dry-run --help --ignore-ipolicy --no-wait-for-sync --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info|show)
    _ganeti_find_first_arg 2 '--priority|--reason' '--all|--debug|--help|--priority=*|--reason=*|--roman|--static|-d|-h|-s'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --help --priority --reason --roman --static -d -h -s'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|--units|-o' '--debug|--filter|--help|--no-headers|--output=*|--reason=*|--separator=*|--units=*|--verbose|-F|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--units=*' --units; then
      _gnt_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --filter --help --no-headers --output --reason --separator --units --verbose -F -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  migrate)
    _ganeti_find_first_arg 2 '--iallocator|--migration-mode|--priority|--reason|--target-node|-I|-n' '--allow-failover|--cleanup|--debug|--dry-run|--force|--help|--iallocator=*|--ignore-hvversions|--ignore-ipolicy|--migration-mode=*|--no-runtime-changes|--non-live|--print-jobid|--priority=*|--reason=*|--submit|--target-node=*|-d|-f|-h'
    if _gnt_checkopt '--migration-mode=*' --migration-mode; then
      _gnt_compgen -W 'live non-live' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--target-node=*' '--target-node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--allow-failover --cleanup --debug --dry-run --force --help --iallocator --ignore-hvversions --ignore-ipolicy --migration-mode --no-runtime-changes --non-live --print-jobid --priority --reason --submit --target-node -I -d -f -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--backend-parameters|--communication|--disk|--disk-template|--ext-params|--file-driver|--file-storage-dir|--hypervisor-parameters|--iallocator|--net|--new-primary|--node|--os-parameters|--os-parameters-private|--os-type|--priority|--reason|--runtime-memory|-B|-H|-I|-O|-c|-e|-m|-n|-o|-t' '--backend-parameters=*|--communication=*|--debug|--disk-template=*|--disk=*|--dry-run|--ext-params=*|--file-driver=*|--file-storage-dir=*|--force|--force-variant|--help|--hypervisor-parameters=*|--iallocator=*|--ignore-ipolicy|--net=*|--new-primary=*|--no-conflicts-check|--no-hotplug|--no-wait-for-sync|--node=*|--offline|--online|--os-parameters-private=*|--os-parameters=*|--os-type=*|--print-jobid|--priority=*|--reason=*|--runtime-memory=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--backend-parameters=*|--disk=*|--hypervisor-parameters=*|--net=*|--os-parameters=*|--os-parameters-private=*|--runtime-memory=*|--ext-params=*|--file-storage-dir=*|--reason=*' '--backend-parameters|-B|--disk|--hypervisor-parameters|-H|--net|--os-parameters|-O|--os-parameters-private|--runtime-memory|-m|--ext-params|-e|--file-storage-dir|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--disk-template=*' '--disk-template|-t'; then
      _gnt_compgen -W 'blockdev diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
      return
    elif _gnt_checkopt '--node=*|--new-primary=*' '--node|-n|--new-primary'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--os-type=*' '--os-type|-o'; then
      _gnt_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--communication=*' '--communication|-c'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    elif _gnt_checkopt '--file-driver=*' --file-driver; then
      _gnt_compgen -W 'blktap blktap2 loop' -- "$optcur"
      return
    fi
    _ganeti_list_options '--backend-parameters --communication --debug --disk --disk-template --dry-run --ext-params --file-driver --file-storage-dir --force --force-variant --help --hypervisor-parameters --iallocator --ignore-ipolicy --net --new-primary --no-conflicts-check --no-hotplug --no-wait-for-sync --node --offline --online --os-parameters --os-parameters-private --os-type --print-jobid --priority --reason --runtime-memory --submit -B -H -I -O -c -d -e -f -h -m -n -o -t'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  move)
    _ganeti_find_first_arg 2 '--compress|--node|--priority|--reason|--shutdown-timeout|-n' '--compress=*|--debug|--dry-run|--force|--help|--ignore-consistency|--ignore-ipolicy|--node=*|--print-jobid|--priority=*|--reason=*|--shutdown-timeout=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--node=*' '--node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--compress=*|--shutdown-timeout=*|--reason=*' '--compress|--shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--compress --debug --dry-run --force --help --ignore-consistency --ignore-ipolicy --node --print-jobid --priority --reason --shutdown-timeout --submit -d -f -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  reboot)
    _ganeti_find_first_arg 2 '--priority|--reason|--shutdown-timeout|--type|-t' '--all|--debug|--dry-run|--force-multiple|--help|--ignore-secondaries|--instance|--node|--node-tags|--pri-node-tags|--primary|--print-jobid|--priority=*|--reason=*|--sec-node-tags|--secondary|--shutdown-timeout=*|--submit|--tags|--type=*|-d|-h'
    if _gnt_checkopt '--type=*' '--type|-t'; then
      _gnt_compgen -W 'full hard soft' -- "$optcur"
      return
    elif _gnt_checkopt '--shutdown-timeout=*|--reason=*' '--shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --dry-run --force-multiple --help --ignore-secondaries --instance --node --node-tags --pri-node-tags --primary --print-jobid --priority --reason --sec-node-tags --secondary --shutdown-timeout --submit --tags --type -d -h -t'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  recreate-disks)
    _ganeti_find_first_arg 2 '--disk|--iallocator|--node|--priority|--reason|-I|-n' '--debug|--disk=*|--dry-run|--help|--iallocator=*|--node=*|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--disk=*|--reason=*' '--disk|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--node=*' '--node|-n'; then
      local tmp= node1= pfx= curvalue="${optcur#*:}"
      if [[ "$optcur" == *:* ]]; then
        node1="${optcur%%:*}"
        if [[ "$COMP_WORDBREAKS" != *:* ]]; then
          pfx="$node1:"
        fi
      fi
      _gnt_log 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
      _gnt_compgen -P "$pfx" -W "$tmp" -- "$curvalue"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --disk --dry-run --help --iallocator --node --print-jobid --priority --reason --submit -I -d -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  reinstall)
    _ganeti_find_first_arg 2 '--os-parameters|--os-parameters-private|--os-parameters-secret|--os-type|--priority|--reason|-O|-o' '--all|--debug|--dry-run|--force|--force-multiple|--force-variant|--help|--instance|--node|--node-tags|--os-parameters-private=*|--os-parameters-secret=*|--os-parameters=*|--os-type=*|--pri-node-tags|--primary|--print-jobid|--priority=*|--reason=*|--sec-node-tags|--secondary|--select-os|--submit|--tags|-d|-f|-h'
    if _gnt_checkopt '--os-type=*' '--os-type|-o'; then
      _gnt_compgen -W "$(_ganeti_os)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--os-parameters=*|--os-parameters-private=*|--os-parameters-secret=*|--reason=*' '--os-parameters|-O|--os-parameters-private|--os-parameters-secret|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --dry-run --force --force-multiple --force-variant --help --instance --node --node-tags --os-parameters --os-parameters-private --os-parameters-secret --os-type --pri-node-tags --primary --print-jobid --priority --reason --sec-node-tags --secondary --select-os --submit --tags -O -d -f -h -o'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '--priority|--reason|--shutdown-timeout' '--debug|--dry-run|--force|--help|--ignore-failures|--print-jobid|--priority=*|--reason=*|--shutdown-timeout=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--shutdown-timeout=*|--reason=*' '--shutdown-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --ignore-failures --print-jobid --priority --reason --shutdown-timeout --submit -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  rename)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--ip-check|--name-check|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --ip-check --name-check --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    elif [[ "$arg_idx" == 1 ]]; then
      compgenargs='-A hostname'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  replace-disks)
    _ganeti_find_first_arg 2 '--disks|--iallocator|--new-secondary|--priority|--reason|-I|-n' '--auto|--debug|--disks=*|--dry-run|--early-release|--help|--iallocator=*|--ignore-ipolicy|--new-secondary=*|--on-primary|--on-secondary|--print-jobid|--priority=*|--reason=*|--submit|-a|-d|-h|-p|-s'
    if _gnt_checkopt '--disks=*|--reason=*' '--disks|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--new-secondary=*' '--new-secondary|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto --debug --disks --dry-run --early-release --help --iallocator --ignore-ipolicy --new-secondary --on-primary --on-secondary --print-jobid --priority --reason --submit -I -a -d -h -n -p -s'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  shutdown|stop)
    _ganeti_find_first_arg 2 '--priority|--reason|--timeout' '--all|--debug|--dry-run|--force|--force-multiple|--help|--ignore-offline|--instance|--no-remember|--node|--node-tags|--pri-node-tags|--primary|--print-jobid|--priority=*|--reason=*|--sec-node-tags|--secondary|--submit|--tags|--timeout=*|-d|-f|-h'
    if _gnt_checkopt '--timeout=*|--reason=*' '--timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --debug --dry-run --force --force-multiple --help --ignore-offline --instance --no-remember --node --node-tags --pri-node-tags --primary --print-jobid --priority --reason --sec-node-tags --secondary --submit --tags --timeout -d -f -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  start|startup)
    _ganeti_find_first_arg 2 '--backend-parameters|--hypervisor-parameters|--priority|--reason|-B|-H' '--all|--backend-parameters=*|--debug|--dry-run|--force|--force-multiple|--help|--hypervisor-parameters=*|--ignore-offline|--instance|--no-remember|--node|--node-tags|--paused|--pri-node-tags|--primary|--print-jobid|--priority=*|--reason=*|--sec-node-tags|--secondary|--submit|--tags|-d|-f|-h'
    if _gnt_checkopt '--hypervisor-parameters=*|--backend-parameters=*|--reason=*' '--hypervisor-parameters|-H|--backend-parameters|-B|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--all --backend-parameters --debug --dry-run --force --force-multiple --help --hypervisor-parameters --ignore-offline --instance --no-remember --node --node-tags --paused --pri-node-tags --primary --print-jobid --priority --reason --sec-node-tags --secondary --submit --tags -B -H -d -f -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_instances)
    fi
    _gnt_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
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'archive autoarchive cancel change-priority info list list-fields show wait watch' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  archive)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  autoarchive)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'1d 1w 4w all'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  cancel)
    _ganeti_find_first_arg 2 --reason '--debug|--force|--help|--kill|--pending|--queued|--reason=*|--waiting|--ya-rly|--yes-do-it|-d|-f|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --kill --pending --queued --reason --waiting --ya-rly --yes-do-it -d -f -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  change-priority)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--force|--help|--pending|--priority=*|--queued|--reason=*|--waiting|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --pending --priority --queued --reason --waiting -d -f -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info|show)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|-o' '--archived|--debug|--error|--filter|--finished|--help|--no-headers|--output=*|--pending|--reason=*|--running|--separator=*|--verbose|-F|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--archived --debug --error --filter --finished --help --no-headers --output --pending --reason --running --separator --verbose -F -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  wait)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  watch)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_jobs)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_job -o filenames gnt-job
_gnt_network() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'add add-tags connect disconnect info list list-fields list-tags modify remove remove-tags rename' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  add)
    _ganeti_find_first_arg 2 '--add-reserved-ips|--gateway|--gateway6|--mac-prefix|--network|--network6|--priority|--reason|--tags|-m' '--add-reserved-ips=*|--debug|--dry-run|--gateway6=*|--gateway=*|--help|--mac-prefix=*|--network6=*|--network=*|--no-conflicts-check|--print-jobid|--priority=*|--reason=*|--submit|--tags=*|-d|-h'
    if _gnt_checkopt '--network=*|--gateway=*|--add-reserved-ips=*|--mac-prefix=*|--network6=*|--gateway6=*|--tags=*|--reason=*' '--network|--gateway|--add-reserved-ips|--mac-prefix|-m|--network6|--gateway6|--tags|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--add-reserved-ips --debug --dry-run --gateway --gateway6 --help --mac-prefix --network --network6 --no-conflicts-check --print-jobid --priority --reason --submit --tags -d -h -m'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  connect)
    _ganeti_find_first_arg 2 '--nic-parameters|--priority|--reason|-N' '--debug|--help|--nic-parameters=*|--no-conflicts-check|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--nic-parameters=*|--reason=*' '--nic-parameters|-N|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --nic-parameters --no-conflicts-check --priority --reason -N -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    elif [[ "$arg_idx" -ge 1 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  disconnect)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    elif [[ "$arg_idx" -ge 1 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|-o' '--debug|--help|--no-headers|--output=*|--reason=*|--separator=*|--verbose|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --reason --separator --verbose -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--add-reserved-ips|--gateway|--gateway6|--mac-prefix|--network6|--priority|--reason|--remove-reserved-ips|-m' '--add-reserved-ips=*|--debug|--dry-run|--gateway6=*|--gateway=*|--help|--mac-prefix=*|--network6=*|--print-jobid|--priority=*|--reason=*|--remove-reserved-ips=*|--submit|-d|-h'
    if _gnt_checkopt '--add-reserved-ips=*|--remove-reserved-ips=*|--gateway=*|--mac-prefix=*|--network6=*|--gateway6=*|--reason=*' '--add-reserved-ips|--remove-reserved-ips|--gateway|--mac-prefix|-m|--network6|--gateway6|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--add-reserved-ips --debug --dry-run --gateway --gateway6 --help --mac-prefix --network6 --print-jobid --priority --reason --remove-reserved-ips --submit -d -h -m'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--force|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --print-jobid --priority --reason --submit -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_network)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  rename)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 && "$arg_idx" -lt 2 ]]; then
      choices="$choices "$(_ganeti_nodegroup)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_network -o filenames gnt-network
_gnt_node() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'add add-tags evacuate failover health info list list-drbd list-fields list-storage list-tags migrate modify modify-storage power powercycle remove remove-tags repair-storage restricted-command show volumes' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  add)
    _ganeti_find_first_arg 2 '--disk-state|--hypervisor-state|--master-capable|--node-group|--node-parameters|--priority|--reason|--secondary-ip|--vm-capable|-g|-s' '--debug|--disk-state=*|--force-join|--help|--hypervisor-state=*|--master-capable=*|--no-node-setup|--no-ssh-key-check|--node-group=*|--node-parameters=*|--priority=*|--readd|--reason=*|--secondary-ip=*|--verbose|--vm-capable=*|-d|-h|-v'
    if _gnt_checkopt '--secondary-ip=*|--node-parameters=*|--hypervisor-state=*|--disk-state=*|--reason=*' '--secondary-ip|-s|--node-parameters|--hypervisor-state|--disk-state|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--master-capable=*|--vm-capable=*' '--master-capable|--vm-capable'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --disk-state --force-join --help --hypervisor-state --master-capable --no-node-setup --no-ssh-key-check --node-group --node-parameters --priority --readd --reason --secondary-ip --verbose --vm-capable -d -g -h -s -v'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      compgenargs='-A hostname'
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  add-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  evacuate)
    _ganeti_find_first_arg 2 '--iallocator|--new-secondary|--priority|--reason|-I|-n' '--debug|--early-release|--force|--help|--iallocator=*|--ignore-soft-errors|--new-secondary=*|--primary-only|--print-jobid|--priority=*|--reason=*|--secondary-only|--submit|-d|-f|-h|-p|-s'
    if _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--new-secondary=*' '--new-secondary|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --early-release --force --help --iallocator --ignore-soft-errors --new-secondary --primary-only --print-jobid --priority --reason --secondary-only --submit -I -d -f -h -n -p -s'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  failover)
    _ganeti_find_first_arg 2 '--iallocator|--priority|--reason|-I' '--debug|--force|--help|--iallocator=*|--ignore-consistency|--priority=*|--reason=*|-d|-f|-h'
    if _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --iallocator --ignore-consistency --priority --reason -I -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  health)
    _ganeti_find_first_arg 2 '--oob-timeout|--priority|--reason|--separator' '--debug|--help|--no-headers|--oob-timeout=*|--priority=*|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--oob-timeout=*|--reason=*' '--separator|--oob-timeout|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --oob-timeout --priority --reason --separator -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info|show)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|--units|-o' '--debug|--filter|--help|--no-headers|--output=*|--reason=*|--separator=*|--units=*|--verbose|-F|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--units=*' --units; then
      _gnt_compgen -W 'g h m t' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --filter --help --no-headers --output --reason --separator --units --verbose -F -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-drbd)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-storage)
    _ganeti_find_first_arg 2 '--output|--priority|--reason|--separator|--storage-type|--units|-o|-t' '--debug|--help|--no-headers|--output=*|--priority=*|--reason=*|--separator=*|--storage-type=*|--units=*|-d|-h'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--units=*' --units; then
      _gnt_compgen -W 'g h m t' -- "$optcur"
      return
    elif _gnt_checkopt '--storage-type=*' '--storage-type|-t'; then
      _gnt_compgen -W 'file gluster lvm-pv lvm-vg sharedfile' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --priority --reason --separator --storage-type --units -d -h -o -t'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-tags)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  migrate)
    _ganeti_find_first_arg 2 '--iallocator|--migration-mode|--priority|--reason|--target-node|-I|-n' '--debug|--force|--help|--iallocator=*|--ignore-ipolicy|--migration-mode=*|--no-runtime-changes|--non-live|--print-jobid|--priority=*|--reason=*|--submit|--target-node=*|-d|-f|-h'
    if _gnt_checkopt '--migration-mode=*' --migration-mode; then
      _gnt_compgen -W 'live non-live' -- "$optcur"
      return
    elif _gnt_checkopt '--target-node=*' '--target-node|-n'; then
      _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
      return
    elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
      _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --force --help --iallocator --ignore-ipolicy --migration-mode --no-runtime-changes --non-live --print-jobid --priority --reason --submit --target-node -I -d -f -h -n'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--disk-state|--drained|--hypervisor-state|--master-candidate|--master-capable|--node-parameters|--node-powered|--offline|--priority|--reason|--secondary-ip|--vm-capable|-C|-D|-O|-s' '--auto-promote|--debug|--disk-state=*|--drained=*|--dry-run|--force|--help|--hypervisor-state=*|--master-candidate=*|--master-capable=*|--node-parameters=*|--node-powered=*|--offline=*|--print-jobid|--priority=*|--reason=*|--secondary-ip=*|--submit|--vm-capable=*|-d|-f|-h'
    if _gnt_checkopt '--master-candidate=*|--drained=*|--offline=*|--master-capable=*|--vm-capable=*|--node-powered=*' '--master-candidate|-C|--drained|-D|--offline|-O|--master-capable|--vm-capable|--node-powered'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    elif _gnt_checkopt '--secondary-ip=*|--node-parameters=*|--hypervisor-state=*|--disk-state=*|--reason=*' '--secondary-ip|-s|--node-parameters|--hypervisor-state|--disk-state|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto-promote --debug --disk-state --drained --dry-run --force --help --hypervisor-state --master-candidate --master-capable --node-parameters --node-powered --offline --print-jobid --priority --reason --secondary-ip --submit --vm-capable -C -D -O -d -f -h -s'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  modify-storage)
    _ganeti_find_first_arg 2 '--allocatable|--priority|--reason' '--allocatable=*|--debug|--dry-run|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--allocatable=*' --allocatable; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--allocatable --debug --dry-run --help --print-jobid --priority --reason --submit -d -h'
    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
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  power)
    _ganeti_find_first_arg 2 '--oob-timeout|--power-delay|--priority|--reason|--separator' '--auto-promote|--debug|--force|--help|--ignore-status|--no-headers|--oob-timeout=*|--power-delay=*|--print-jobid|--priority=*|--reason=*|--separator=*|--submit|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--separator=*|--oob-timeout=*|--power-delay=*|--reason=*' '--separator|--oob-timeout|--power-delay|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--auto-promote --debug --force --help --ignore-status --no-headers --oob-timeout --power-delay --print-jobid --priority --reason --separator --submit -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "'on off cycle status'
    elif [[ "$arg_idx" -ge 1 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  powercycle)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--force|--help|--print-jobid|--priority=*|--reason=*|--submit|--yes|-d|-f|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --force --help --print-jobid --priority --reason --submit --yes -d -f -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  remove-tags)
    _ganeti_find_first_arg 2 '--from|--priority|--reason' '--debug|--from=*|--help|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--from=*|--reason=*' '--from|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --from --help --print-jobid --priority --reason --submit -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  repair-storage)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--dry-run|--help|--ignore-consistency|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --dry-run --help --ignore-consistency --print-jobid --priority --reason --submit -d -h'
    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
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  restricted-command)
    _ganeti_find_first_arg 2 '--node-group|--priority|--reason|-g' '--debug|--help|--node-group=*|--print-jobid|--priority=*|--reason=*|--show-machine-names|--submit|--sync|-M|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--node-group=*' '--node-group|-g'; then
      _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --node-group --print-jobid --priority --reason --show-machine-names --submit --sync -M -d -g -h'
    compgenargs=
    if [[ "$arg_idx" -ge 1 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  volumes)
    _ganeti_find_first_arg 2 '--output|--priority|--reason|--separator|--units|-o' '--debug|--help|--no-headers|--output=*|--priority=*|--reason=*|--separator=*|--units=*|-d|-h'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--units=*' --units; then
      _gnt_compgen -W 'g h m t' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --priority --reason --separator --units -d -h -o'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_nodes)
    fi
    _gnt_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
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'diagnose info list modify show' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  diagnose)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  info|show)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_os)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--no-headers|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --priority --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  modify)
    _ganeti_find_first_arg 2 '--blacklisted|--hidden|--hypervisor-parameters|--os-parameters|--os-parameters-private|--priority|--reason|-H|-O' '--blacklisted=*|--debug|--dry-run|--help|--hidden=*|--hypervisor-parameters=*|--os-parameters-private=*|--os-parameters=*|--print-jobid|--priority=*|--reason=*|--submit|-d|-h'
    if _gnt_checkopt '--hypervisor-parameters=*|--os-parameters=*|--os-parameters-private=*|--reason=*' '--hypervisor-parameters|-H|--os-parameters|-O|--os-parameters-private|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    elif _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--hidden=*|--blacklisted=*' '--hidden|--blacklisted'; then
      _gnt_compgen -W 'no yes' -- "$optcur"
      return
    fi
    _ganeti_list_options '--blacklisted --debug --dry-run --help --hidden --hypervisor-parameters --os-parameters --os-parameters-private --print-jobid --priority --reason --submit -H -O -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_os)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_os -o filenames gnt-os
_gnt_storage() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'diagnose info' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  diagnose)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 '--priority|--reason' '--debug|--help|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*' --priority; then
      _gnt_compgen -W 'high low normal' -- "$optcur"
      return
    elif _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_os)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_storage -o filenames gnt-storage
_gnt_filter() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'add delete info list list-fields replace' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  add)
    _ganeti_find_first_arg 2 '--action|--predicates|--priority|--reason' '--action=*|--debug|--help|--predicates=*|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*|--predicates=*|--action=*|--reason=*' '--priority|--predicates|--action|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--action --debug --help --predicates --priority --reason -d -h'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  delete)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_filter)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  info)
    _ganeti_find_first_arg 2 --reason '--debug|--help|--reason=*|-d|-h'
    if _gnt_checkopt '--reason=*' --reason; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_filter)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list)
    _ganeti_find_first_arg 2 '--output|--reason|--separator|-o' '--debug|--help|--no-headers|--output=*|--reason=*|--separator=*|--verbose|-d|-h|-v'
    if _gnt_checkopt '--separator=*|--output=*|--reason=*' '--separator|--output|-o|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --output --reason --separator --verbose -d -h -o -v'
    compgenargs=
    if [[ "$arg_idx" -ge 0 ]]; then
      choices="$choices "$(_ganeti_filter)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  list-fields)
    _ganeti_find_first_arg 2 '--reason|--separator' '--debug|--help|--no-headers|--reason=*|--separator=*|-d|-h'
    if _gnt_checkopt '--separator=*|--reason=*' '--separator|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--debug --help --no-headers --reason --separator -d -h'
    compgenargs=
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  replace)
    _ganeti_find_first_arg 2 '--action|--predicates|--priority|--reason' '--action=*|--debug|--help|--predicates=*|--priority=*|--reason=*|-d|-h'
    if _gnt_checkopt '--priority=*|--predicates=*|--action=*|--reason=*' '--priority|--predicates|--action|--reason'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--action --debug --help --predicates --priority --reason -d -h'
    compgenargs=
    if [[ "$arg_idx" == 0 ]]; then
      choices="$choices "$(_ganeti_filter)
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _gnt_filter -o filenames gnt-filter
_ganeti_burnin() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--disk-growth|--disk-size|--disk-template|--hypervisor-parameters|--iallocator|--maxmem-size|--mem-size|--minmem-size|--net-timeout|--nodes|--os|--os-parameters|--reason|--reboot-types|--rename|--vcpu-count|-H|-I|-O|-n|-o|-t' '--debug|--disk-growth=*|--disk-size=*|--disk-template=*|--early-release|--http-check|--hypervisor-parameters=*|--iallocator=*|--ip-check|--keep-instances|--maxmem-size=*|--mem-size=*|--minmem-size=*|--name-check|--net-timeout=*|--no-activate-disks|--no-add-disks|--no-add-nics|--no-confd|--no-failover|--no-importexport|--no-migrate|--no-move|--no-nics|--no-reboot|--no-reinstall|--no-renamesame|--no-replace1|--no-replace2|--no-startstop|--nodes=*|--os-parameters=*|--os=*|--parallel|--reason=*|--reboot-types=*|--rename=*|--vcpu-count=*|--verbose|-C|-K|-d|-p|-v'
  if _gnt_checkopt '--os=*' '--os|-o'; then
    _gnt_compgen -W "$(_ganeti_os)" -- "$optcur"
    return
  elif _gnt_checkopt '--hypervisor-parameters=*|--os-parameters=*|--disk-growth=*|--reboot-types=*|--rename=*|--reason=*' '--hypervisor-parameters|-H|--os-parameters|-O|--disk-growth|--reboot-types|--rename|--reason'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--disk-size=*' --disk-size; then
    _gnt_compgen -W '10G 1G 1G,256M 4G 4G,1G,1G 512M' -- "$optcur"
    return
  elif _gnt_checkopt '--mem-size=*|--maxmem-size=*|--minmem-size=*' '--mem-size|--maxmem-size|--minmem-size'; then
    _gnt_compgen -W '128M 12G 16G 1G 256M 4G 512M 8G' -- "$optcur"
    return
  elif _gnt_checkopt '--vcpu-count=*' --vcpu-count; then
    _gnt_compgen -W '1 2 3 4' -- "$optcur"
    return
  elif _gnt_checkopt '--disk-template=*' '--disk-template|-t'; then
    _gnt_compgen -W 'diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
    return
  elif _gnt_checkopt '--nodes=*' '--nodes|-n'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--iallocator=*' '--iallocator|-I'; then
    _gnt_compgen -W "$(_ganeti_iallocator)" -- "$optcur"
    return
  elif _gnt_checkopt '--net-timeout=*' --net-timeout; then
    _gnt_compgen -W '15 300 60 900' -- "$optcur"
    return
  fi
  _ganeti_list_options '--debug --disk-growth --disk-size --disk-template --early-release --http-check --hypervisor-parameters --iallocator --ip-check --keep-instances --maxmem-size --mem-size --minmem-size --name-check --net-timeout --no-activate-disks --no-add-disks --no-add-nics --no-confd --no-failover --no-importexport --no-migrate --no-move --no-nics --no-reboot --no-reinstall --no-renamesame --no-replace1 --no-replace2 --no-startstop --nodes --os --os-parameters --parallel --reason --reboot-types --rename --vcpu-count --verbose -C -H -I -K -O -d -n -o -p -t -v'
  compgenargs=
  if [[ "$arg_idx" -ge 0 ]]; then
    choices="$choices "$(_ganeti_instances)
  fi
  _gnt_compgen -W "$choices" $compgenargs -- "$cur"
  return
}
complete -F _ganeti_burnin -o filenames /usr/lib64/ganeti/tools/burnin
_ganeti_cleaner() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  first_arg_idx=1
  _ganeti_list_options ''
  compgenargs=
  if [[ "$arg_idx" == 0 ]]; then
    choices="$choices "'node master'
  fi
  _gnt_compgen -W "$choices" $compgenargs -- "$cur"
  return
}
complete -F _ganeti_cleaner -o filenames ganeti-cleaner
_htools_harep() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--job-delay|--luxi|-L' '--dry-run|--help|--help-completion|--job-delay=*|--luxi=*|--reason|--version|-V|-h'
  if _gnt_checkopt '--luxi=*|--job-delay=*' '--luxi|-L|--job-delay'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  fi
  _ganeti_list_options '--dry-run --help --help-completion --job-delay --luxi --reason --version -L -V -h'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_harep -o filenames harep
_htools_hbal() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--dynu-file|--exclude-instances|--exclusion-tags|--group|--ialloc-src|--luxi|--master|--max-cpu|--max-length|--min-disk|--min-gain|--min-gain-limit|--min-score|--mond|--mond-data|--offline|--priority|--select-instances|--static-kvm-node-memory|--text-data|-G|-I|-L|-O|-U|-e|-g|-l|-m|-t' '--dynu-file=*|--evac-mode|--exclude-instances=*|--exclusion-tags=*|--exec|--exit-on-missing-mond-data|--first-job-group|--group=*|--help|--help-completion|--ialloc-src=*|--ignore-dynu|--ignore-soft-errors|--luxi=*|--master=*|--max-cpu=*|--max-length=*|--min-disk=*|--min-gain-limit=*|--min-gain=*|--min-score=*|--mond-data=*|--mond-xen|--mond=*|--no-disk-moves|--no-instance-moves|--offline=*|--print-commands|--print-instances|--print-nodes|--priority=*|--quiet|--reason|--restricted-migration|--save|--select-instances=*|--static-kvm-node-memory=*|--text-data=*|--verbose|--version|-C|-E|-S|-V|-X|-h|-p|-q|-v'
  if _gnt_checkopt '--text-data=*|--master=*|--luxi=*|--ialloc-src=*|--max-length=*|--static-kvm-node-memory=*|--min-score=*|--max-cpu=*|--min-disk=*|--min-gain=*|--min-gain-limit=*|--select-instances=*|--dynu-file=*|--mond-data=*|--exclusion-tags=*|--exclude-instances=*' '--text-data|-t|--master|-m|--luxi|-L|--ialloc-src|-I|--max-length|-l|--static-kvm-node-memory|--min-score|-e|--max-cpu|--min-disk|--min-gain|-g|--min-gain-limit|--select-instances|--dynu-file|-U|--mond-data|--exclusion-tags|--exclude-instances'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--group=*' '--group|-G'; then
    _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
    return
  elif _gnt_checkopt '--offline=*' '--offline|-O'; then
    _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
    return
  elif _gnt_checkopt '--mond=*' --mond; then
    _gnt_compgen -W 'no yes' -- "$optcur"
    return
  elif _gnt_checkopt '--priority=*' --priority; then
    _gnt_compgen -W 'high low normal' -- "$optcur"
    return
  fi
  _ganeti_list_options '--dynu-file --evac-mode --exclude-instances --exclusion-tags --exec --exit-on-missing-mond-data --first-job-group --group --help --help-completion --ialloc-src --ignore-dynu --ignore-soft-errors --luxi --master --max-cpu --max-length --min-disk --min-gain --min-gain-limit --min-score --mond --mond-data --mond-xen --no-disk-moves --no-instance-moves --offline --print-commands --print-instances --print-nodes --priority --quiet --reason --restricted-migration --save --select-instances --static-kvm-node-memory --text-data --verbose --version -C -E -G -I -L -O -S -U -V -X -e -g -h -l -m -p -q -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hbal -o filenames hbal
_htools_hscan() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--luxi|--output-dir|--static-kvm-node-memory|-L|-d' '--help|--help-completion|--luxi=*|--no-headers|--output-dir=*|--print-nodes|--static-kvm-node-memory=*|--verbose|--version|-V|-h|-p|-v'
  if _gnt_checkopt '--output-dir=*|--luxi=*|--static-kvm-node-memory=*' '--output-dir|-d|--luxi|-L|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  fi
  _ganeti_list_options '--help --help-completion --luxi --no-headers --output-dir --print-nodes --static-kvm-node-memory --verbose --version -L -V -d -h -p -v'
  compgenargs=
  if [[ "$arg_idx" -ge 0 ]]; then
    compgenargs='-A hostname'
  fi
  _gnt_compgen -W "$choices" $compgenargs -- "$cur"
  return
}
complete -F _htools_hscan -o filenames hscan
_htools_hspace() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--disk-template|--ialloc-src|--luxi|--machine-readable|--master|--max-cpu|--max-length|--min-disk|--offline|--simulate|--spindle-use|--standard-alloc|--static-kvm-node-memory|--text-data|--tiered-alloc|-I|-L|-O|-l|-m|-t' '--accept-existing-errors|--disk-template=*|--help|--help-completion|--ialloc-src=*|--independent-groups|--luxi=*|--machine-readable=*|--master=*|--max-cpu=*|--max-length=*|--min-disk=*|--no-capacity-checks|--offline=*|--print-nodes|--quiet|--save|--simulate=*|--spindle-use=*|--standard-alloc=*|--static-kvm-node-memory=*|--text-data=*|--tiered-alloc=*|--verbose|--version|-S|-V|-h|-p|-q|-v'
  if _gnt_checkopt '--text-data=*|--spindle-use=*|--simulate=*|--master=*|--luxi=*|--ialloc-src=*|--max-cpu=*|--max-length=*|--min-disk=*|--standard-alloc=*|--tiered-alloc=*|--static-kvm-node-memory=*' '--text-data|-t|--spindle-use|--simulate|--master|-m|--luxi|-L|--ialloc-src|-I|--max-cpu|--max-length|-l|--min-disk|--standard-alloc|--tiered-alloc|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--disk-template=*' --disk-template; then
    _gnt_compgen -W 'blockdev diskless drbd ext file gluster plain rbd sharedfile' -- "$optcur"
    return
  elif _gnt_checkopt '--offline=*' '--offline|-O'; then
    _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
    return
  elif _gnt_checkopt '--machine-readable=*' --machine-readable; then
    _gnt_compgen -W 'no yes' -- "$optcur"
    return
  fi
  _ganeti_list_options '--accept-existing-errors --disk-template --help --help-completion --ialloc-src --independent-groups --luxi --machine-readable --master --max-cpu --max-length --min-disk --no-capacity-checks --offline --print-nodes --quiet --save --simulate --spindle-use --standard-alloc --static-kvm-node-memory --text-data --tiered-alloc --verbose --version -I -L -O -S -V -h -l -m -p -q -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hspace -o filenames hspace
_htools_hinfo() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--ialloc-src|--luxi|--master|--mond|--mond-data|--offline|--static-kvm-node-memory|--text-data|-I|-L|-O|-m|-t' '--help|--help-completion|--ialloc-src=*|--ignore-dynu|--luxi=*|--master=*|--mond-data=*|--mond=*|--offline=*|--print-instances|--print-nodes|--quiet|--static-kvm-node-memory=*|--text-data=*|--verbose|--version|-V|-h|-p|-q|-v'
  if _gnt_checkopt '--text-data=*|--master=*|--luxi=*|--ialloc-src=*|--mond-data=*|--static-kvm-node-memory=*' '--text-data|-t|--master|-m|--luxi|-L|--ialloc-src|-I|--mond-data|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--offline=*' '--offline|-O'; then
    _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
    return
  elif _gnt_checkopt '--mond=*' --mond; then
    _gnt_compgen -W 'no yes' -- "$optcur"
    return
  fi
  _ganeti_list_options '--help --help-completion --ialloc-src --ignore-dynu --luxi --master --mond --mond-data --offline --print-instances --print-nodes --quiet --static-kvm-node-memory --text-data --verbose --version -I -L -O -V -h -m -p -q -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hinfo -o filenames hinfo
_htools_hcheck() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--dynu-file|--exclude-instances|--exclusion-tags|--ialloc-src|--luxi|--machine-readable|--master|--max-cpu|--max-length|--min-disk|--min-gain|--min-gain-limit|--min-score|--offline|--select-instances|--text-data|-I|-L|-O|-U|-e|-g|-l|-m|-t' '--dynu-file=*|--evac-mode|--exclude-instances=*|--exclusion-tags=*|--help|--help-completion|--ialloc-src=*|--ignore-dynu|--ignore-soft-errors|--luxi=*|--machine-readable=*|--master=*|--max-cpu=*|--max-length=*|--min-disk=*|--min-gain-limit=*|--min-gain=*|--min-score=*|--no-capacity-checks|--no-disk-moves|--no-instance-moves|--no-simulation|--offline=*|--quiet|--select-instances=*|--text-data=*|--verbose|--version|-E|-V|-h|-q|-v'
  if _gnt_checkopt '--text-data=*|--dynu-file=*|--exclude-instances=*|--exclusion-tags=*|--ialloc-src=*|--luxi=*|--max-cpu=*|--max-length=*|--min-disk=*|--min-gain=*|--min-gain-limit=*|--min-score=*|--master=*|--select-instances=*' '--text-data|-t|--dynu-file|-U|--exclude-instances|--exclusion-tags|--ialloc-src|-I|--luxi|-L|--max-cpu|--max-length|-l|--min-disk|--min-gain|-g|--min-gain-limit|--min-score|-e|--master|-m|--select-instances'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--machine-readable=*' --machine-readable; then
    _gnt_compgen -W 'no yes' -- "$optcur"
    return
  elif _gnt_checkopt '--offline=*' '--offline|-O'; then
    _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
    return
  fi
  _ganeti_list_options '--dynu-file --evac-mode --exclude-instances --exclusion-tags --help --help-completion --ialloc-src --ignore-dynu --ignore-soft-errors --luxi --machine-readable --master --max-cpu --max-length --min-disk --min-gain --min-gain-limit --min-score --no-capacity-checks --no-disk-moves --no-instance-moves --no-simulation --offline --quiet --select-instances --text-data --verbose --version -E -I -L -O -U -V -e -g -h -l -m -q -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hcheck -o filenames hcheck
_htools_hroller() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--group|--ialloc-src|--luxi|--master|--node-tags|--offline|--static-kvm-node-memory|--text-data|-G|-I|-L|-O|-m|-t' '--force|--full-evacuation|--group=*|--help|--help-completion|--ialloc-src=*|--ignore-non-redundant|--luxi=*|--master=*|--no-headers|--node-tags=*|--offline-maintenance|--offline=*|--one-step-only|--print-moves|--quiet|--save|--skip-non-redundant|--static-kvm-node-memory=*|--text-data=*|--verbose|--version|-S|-V|-f|-h|-q|-v'
  if _gnt_checkopt '--luxi=*|--master=*|--text-data=*|--ialloc-src=*|--node-tags=*|--static-kvm-node-memory=*' '--luxi|-L|--master|-m|--text-data|-t|--ialloc-src|-I|--node-tags|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--offline=*' '--offline|-O'; then
    _gnt_compgen -W "$(_ganeti_nodes)" -- "$optcur"
    return
  elif _gnt_checkopt '--group=*' '--group|-G'; then
    _gnt_compgen -W "$(_ganeti_nodegroup)" -- "$optcur"
    return
  fi
  _ganeti_list_options '--force --full-evacuation --group --help --help-completion --ialloc-src --ignore-non-redundant --luxi --master --no-headers --node-tags --offline --offline-maintenance --one-step-only --print-moves --quiet --save --skip-non-redundant --static-kvm-node-memory --text-data --verbose --version -G -I -L -O -S -V -f -h -m -q -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hroller -o filenames hroller
_htools_hsqueeze() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--luxi|--minimal-resources|--static-kvm-node-memory|--target-resources|--text-data|-L|-t' '--exec|--help|--help-completion|--luxi=*|--minimal-resources=*|--no-headers|--print-commands|--save|--static-kvm-node-memory=*|--target-resources=*|--text-data=*|--verbose|--version|-C|-S|-V|-X|-h|-v'
  if _gnt_checkopt '--luxi=*|--text-data=*|--minimal-resources=*|--target-resources=*|--static-kvm-node-memory=*' '--luxi|-L|--text-data|-t|--minimal-resources|--target-resources|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  fi
  _ganeti_list_options '--exec --help --help-completion --luxi --minimal-resources --no-headers --print-commands --save --static-kvm-node-memory --target-resources --text-data --verbose --version -C -L -S -V -X -h -t -v'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _htools_hsqueeze -o filenames hsqueeze
_htools_hail() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--mond|--restrict-allocation-to|--simulate|--static-kvm-node-memory|--text-data|-t' '--help|--help-completion|--ignore-dynu|--ignore-soft-errors|--mond-xen|--mond=*|--no-capacity-checks|--print-nodes|--restrict-allocation-to=*|--save|--simulate=*|--static-kvm-node-memory=*|--text-data=*|--verbose|--version|-S|-V|-h|-p|-v'
  if _gnt_checkopt '--text-data=*|--simulate=*|--restrict-allocation-to=*|--static-kvm-node-memory=*' '--text-data|-t|--simulate|--restrict-allocation-to|--static-kvm-node-memory'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--mond=*' --mond; then
    _gnt_compgen -W 'no yes' -- "$optcur"
    return
  fi
  _ganeti_list_options '--help --help-completion --ignore-dynu --ignore-soft-errors --mond --mond-xen --no-capacity-checks --print-nodes --restrict-allocation-to --save --simulate --static-kvm-node-memory --text-data --verbose --version -S -V -h -p -t -v'
  compgenargs=
  if [[ "$arg_idx" == 0 ]]; then
    compgenargs=-f
  fi
  _gnt_compgen -W "$choices" $compgenargs -- "$cur"
  return
}
complete -F _htools_hail -o filenames hail
_ganeti_confd() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  _ganeti_find_first_arg 1 '--bind|--port|--syslog|-b|-p' '--bind=*|--debug|--foreground|--help|--help-completion|--no-user-checks|--port=*|--syslog=*|--version|-V|-d|-f|-h'
  if _gnt_checkopt '--port=*|--bind=*' '--port|-p|--bind|-b'; then
    _gnt_compgen -W '' -- "$optcur"
    return
  elif _gnt_checkopt '--syslog=*' --syslog; then
    _gnt_compgen -W 'no only yes' -- "$optcur"
    return
  fi
  _ganeti_list_options '--bind --debug --foreground --help --help-completion --no-user-checks --port --syslog --version -V -b -d -f -h -p'
  _gnt_compgen -W "$choices" -- "$cur"
  return
}
complete -F _ganeti_confd -o filenames ganeti-confd
_mon_collector() {
  local  cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" i first_arg_idx choices compgenargs arg_idx optcur
  _gnt_log cur="$cur" prev="$prev"
  [[ -n "$GANETI_COMPL_LOG" ]] && _gnt_log "$(set | grep ^COMP_)"
  COMPREPLY=()
  if [[ "$COMP_CWORD" == 1 ]]; then
    _gnt_compgen -W 'diskstats drbd inst-status-xen lv' -- "$cur"
    return
  fi
  case "${COMP_WORDS[1]}" in
  diskstats)
    _ganeti_find_first_arg 2 '--file|-f' '--file=*|--help|--help-completion|--version|-V|-h'
    if _gnt_checkopt '--file=*' '--file|-f'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--file --help --help-completion --version -V -f -h'
    compgenargs=
    if [[ "$arg_idx" -ge 0 && "$arg_idx" -lt 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  drbd)
    _ganeti_find_first_arg 2 '--drbd-pairing|--drbd-status|-p|-s' '--drbd-pairing=*|--drbd-status=*|--help|--help-completion|--version|-V|-h'
    if _gnt_checkopt '--drbd-status=*|--drbd-pairing=*' '--drbd-status|-s|--drbd-pairing|-p'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--drbd-pairing --drbd-status --help --help-completion --version -V -h -p -s'
    compgenargs=
    if [[ "$arg_idx" -ge 0 && "$arg_idx" -lt 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  inst-status-xen)
    _ganeti_find_first_arg 2 '--address|--port|-a|-p' '--address=*|--help|--help-completion|--port=*|--version|-V|-h'
    if _gnt_checkopt '--address=*|--port=*' '--address|-a|--port|-p'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--address --help --help-completion --port --version -V -a -h -p'
    _gnt_compgen -W "$choices" -- "$cur"
    return
  ;;
  lv)
    _ganeti_find_first_arg 2 '--address|--file|--instances|--port|-a|-f|-i|-p' '--address=*|--file=*|--help|--help-completion|--instances=*|--port=*|--version|-V|-h'
    if _gnt_checkopt '--file=*|--address=*|--port=*|--instances=*' '--file|-f|--address|-a|--port|-p|--instances|-i'; then
      _gnt_compgen -W '' -- "$optcur"
      return
    fi
    _ganeti_list_options '--address --file --help --help-completion --instances --port --version -V -a -f -h -i -p'
    compgenargs=
    if [[ "$arg_idx" -ge 0 && "$arg_idx" -lt 0 ]]; then
      compgenargs=-f
    fi
    _gnt_compgen -W "$choices" $compgenargs -- "$cur"
    return
  ;;
  esac
}
complete -F _mon_collector -o filenames mon-collector
[[ -n "$gnt_shopt_extglob" ]] && $gnt_shopt_extglob
unset gnt_shopt_extglob

