
    _pcs()
    {
    local cur cur1 cur2 cur3
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    if [ "$COMP_CWORD" -gt "0" ]; then cur1="${COMP_WORDS[COMP_CWORD-1]}";fi
    if [ "$COMP_CWORD" -gt "1" ]; then cur2="${COMP_WORDS[COMP_CWORD-2]}";fi
    if [ "$COMP_CWORD" -gt "2" ]; then cur3="${COMP_WORDS[COMP_CWORD-3]}";fi

    
case "${cur3}" in
  pcsd)
    ;;
  status)
    ;;
  config)
  case "${cur2}" in
    checkpoint)
      ;;
    export)
      case "${cur1}" in
        pcs-commands|pcs-commands-verbose)
          COMPREPLY=($(compgen -W "output=<filename>" -- ${cur}))
          return 0
          ;;
        *)
        ;;
      esac
      
      ;;
    import-cman)
      ;;
    *)
    ;;
  esac
  
    ;;
  acl)
    ;;
  node)
    ;;
  cluster)
    ;;
  constraint)
    ;;
  resource)
    ;;
  property)
    ;;
  stonith)
    ;;
  *)
  ;;
esac


case "${cur2}" in
  pcsd)
    ;;
  status)
    ;;
  config)
  case "${cur1}" in
    checkpoint)
      COMPREPLY=($(compgen -W "view restore" -- ${cur}))
      return 0
      ;;
    export)
      COMPREPLY=($(compgen -W "pcs-commands pcs-commands-verbose" -- ${cur}))
      return 0
      ;;
    import-cman)
      COMPREPLY=($(compgen -W "output=<filename>" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  acl)
  case "${cur1}" in
    group)
      COMPREPLY=($(compgen -W "delete create" -- ${cur}))
      return 0
      ;;
    user)
      COMPREPLY=($(compgen -W "delete create" -- ${cur}))
      return 0
      ;;
    role)
      COMPREPLY=($(compgen -W "unassign delete assign create" -- ${cur}))
      return 0
      ;;
    permission)
      COMPREPLY=($(compgen -W "add delete" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  node)
    ;;
  cluster)
  case "${cur1}" in
    uidgid)
      COMPREPLY=($(compgen -W "add rm" -- ${cur}))
      return 0
      ;;
    remote-node)
      COMPREPLY=($(compgen -W "add remove" -- ${cur}))
      return 0
      ;;
    node)
      COMPREPLY=($(compgen -W "add remove" -- ${cur}))
      return 0
      ;;
    quorum)
      COMPREPLY=($(compgen -W "unblock" -- ${cur}))
      return 0
      ;;
    reload)
      COMPREPLY=($(compgen -W "corosync" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  constraint)
  case "${cur1}" in
    rule)
      COMPREPLY=($(compgen -W "add remove" -- ${cur}))
      return 0
      ;;
    colocation)
      COMPREPLY=($(compgen -W "set add remove show" -- ${cur}))
      return 0
      ;;
    order)
      COMPREPLY=($(compgen -W "set remove show" -- ${cur}))
      return 0
      ;;
    location)
      COMPREPLY=($(compgen -W "add remove show" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  resource)
  case "${cur1}" in
    failcount)
      COMPREPLY=($(compgen -W "reset show" -- ${cur}))
      return 0
      ;;
    op)
      COMPREPLY=($(compgen -W "add defaults remove" -- ${cur}))
      return 0
      ;;
    group)
      COMPREPLY=($(compgen -W "add remove" -- ${cur}))
      return 0
      ;;
    relocate)
      COMPREPLY=($(compgen -W "clear run dry-run show" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  property)
    ;;
  stonith)
  case "${cur1}" in
    level)
      COMPREPLY=($(compgen -W "add verify clear remove" -- ${cur}))
      return 0
      ;;
    *)
    ;;
  esac
  
    ;;
  *)
  ;;
esac


case "${cur1}" in
  pcsd)
    COMPREPLY=($(compgen -W "clear-auth certkey sync-certificates" -- ${cur}))
    return 0
    ;;
  status)
    COMPREPLY=($(compgen -W "pcsd groups nodes xml corosync cluster resources" -- ${cur}))
    return 0
    ;;
  config)
    COMPREPLY=($(compgen -W "checkpoint restore backup export import-cman" -- ${cur}))
    return 0
    ;;
  acl)
    COMPREPLY=($(compgen -W "group enable user role permission disable" -- ${cur}))
    return 0
    ;;
  node)
    COMPREPLY=($(compgen -W "standby unmaintenance maintenance utilization unstandby" -- ${cur}))
    return 0
    ;;
  cluster)
    COMPREPLY=($(compgen -W "status stop sync uidgid cib-upgrade cib cib-push enable destroy report auth remote-node setup kill node start quorum pcsd-status reload corosync edit verify disable" -- ${cur}))
    return 0
    ;;
  constraint)
    COMPREPLY=($(compgen -W "rule colocation remove order ref location" -- ${cur}))
    return 0
    ;;
  resource)
    COMPREPLY=($(compgen -W "delete debug-monitor defaults debug-start move failcount providers cleanup op describe clone standards ungroup debug-stop manage meta list unmanage group relocate debug-demote unclone update utilization create debug-promote enable restart agents master clear ban disable" -- ${cur}))
    return 0
    ;;
  property)
    COMPREPLY=($(compgen -W "set unset" -- ${cur}))
    return 0
    ;;
  stonith)
    COMPREPLY=($(compgen -W "cleanup delete level list describe confirm fence update create" -- ${cur}))
    return 0
    ;;
  *)
  ;;
esac



    if [ $COMP_CWORD -eq 1 ]; then
        COMPREPLY=( $(compgen -W "resource cluster stonith property acl constraint status config pcsd node" -- $cur) )
    fi
    return 0

    }
    complete -F _pcs pcs
    
