#compdef isi diskpools

# Copyright C 2002-2011 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

(( $+functions[__isi_diskpools] )) ||
_isi_diskpools() {
  if (( CURRENT == 2 )); then
    _tags commands && {compadd $@ create new modify edit delete rm list ls reprovision}
    _arguments \
      '--help[Print usage help and exit]'
  else
    local cmd=${words[2]}
    (( CURRENT-- ))
    shift words
    if [[ $cmd == create ]] || [[ $cmd == new ]]; then
      curcontext="${curcontext%:*:*}:isi-diskpools-create:"
      _isi_diskpools_create
    elif [[ $cmd == modify ]] || [[ $cmd == edit ]]; then
      curcontext="${curcontext%:*:*}:isi-diskpools-modify:"
      _isi_diskpools_modify
    elif [[ $cmd == delete ]] || [[ $cmd == rm ]]; then
      curcontext="${curcontext%:*:*}:isi-diskpools-delete:"
      _isi_diskpools_delete
    elif [[ $cmd == list ]] || [[ $cmd == ls ]]; then
      curcontext="${curcontext%:*:*}:isi-diskpools-list:"
      _isi_diskpools_list
    elif [[ $cmd == reprovision ]]; then
      curcontext="${curcontext%:*:*}:isi-diskpools-reprovision:"
      _isi_diskpools_reprovision
    fi
  fi
}

(( $+functions[_isi_diskpools_create] )) ||
_isi_diskpools_create() {
  _arguments \
    '--name=[User-specified name of the disk pool]' \
    '--policy[Create a disk pool policy]' \
    '--set-policy=[Specify the order of groups or pools (e.g., <entry name | entry id>, ...)]' \
    '--group[Create a node group]' \
    '--add-pool-and-groups=[Add pool or group by name or ID to the group (e.g., <entry name | entry id>, ...)]' \
    '--tier[Create a tier]' \
    '--diskpool[Create a diskpool]' \
    '--add-drives=[Add member drive to the disk pool (e.g., <lnn>:<ldnum>,...)]' \
    '--protection=[Default protection for files assigned to this disk pool (e.g., N+M or 1-8x)]' \
    '--system=[Allow this disk pool to store system data]' \
    '--vhs-limit=[Number of drives worth of free space to maintain across the pool]' \
    '--vhs-hide-spare=[Display the available bytes excluding the virtual hotspare in df and the like]' \
    '--vhs-deny-writes=[Fail writes once the virtual hotspare limit is reached]' \
    '--quiet[Print minimal output]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_diskpools_modify] )) ||
_isi_diskpools_modify() {
  _values 'pool' \
    $(isi diskpool list -q)
  _arguments \
    '--pool=[Name or ID of the disk pool]' \
    '--new-name=[New name for the disk pool]' \
    '--add-drives=[Add member drive to the disk pool (e.g., <lnn>:<ldnum>,...)]' \
    '--remove-drives=[Remove member drive from the disk pool (e.g., <lnn>:<ldnum>,...)]' \
    '--add-pool-and-groups=[Add pool or group by name or ID to the group (e.g., <entry name | entry id>,...)]' \
    '--remove-pools-and-groups=[Remove pool or group by name or ID from the group (e.g., <entry name | entry id>,...)]' \
    '--set-policy=[Specify the order of the groups or pools (e.g., <entry name | entry id>, ...]' \
    '--protection=[Default protection for files assigned to this disk pool (e.g., N+M or 1-8x)]' \
    '--system=[Allow this disk pool to store system data]' \
    '--vhs-limit=[Number of drives worth of free space to maintain across the pool]' \
    '--vhs-hide-spare=[Display the available bytes excluding the virtual hotspare in df and the like]' \
    '--vhs-deny-writes=[Fail writes once the virtual hotspare limit is reached]' \
    '--quiet[Print minimal output]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_diskpools_delete] )) ||
_isi_diskpools_delete() {
  _values 'pool' \
    $(isi diskpool list -q)
  _arguments \
    '--pool=[Name or ID of the disk pool]' \
    '--quiet[Print minimal output]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_diskpools_list] )) ||
_isi_diskpools_list() {
  _arguments \
    '--verbose[Print verbose output]' \
    '--quiet[Print minimal output]' \
    '--include-reserved[Only show reserved entries]' \
    '--diskpool[Show only disk pools]' \
    '--group[Show only node groups]' \
    '--policy[Show only policies]' \
    '--tier[Show only tiers]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_diskpools_reprovision] )) ||
_isi_diskpools_reprovision() {
  _arguments \
    '--quiet[Print minimal output]' \
    '--help[Print usage help and exit]'
}

