Files
one/share/shell/bash_completion
T
54d9fd6f0c F OpenNebula/one#7638: Add Open vSwitch port mirroring
Add port mirroring for Virtual Networks using the ovswitch and ovswitch_vxlan drivers, allowing selected VM interfaces to send copies of their traffic to external monitoring tools. Support RSPAN output through a VLAN and GRE or ERSPAN tunnels, including ERSPAN types II and III.

Introduce Virtual Network MIRROR definitions with an automatically assigned MIRROR_ID, NAME, optional DESCRIPTION, and TYPE. Select source interfaces through PORTS, expressed as comma-separated VM_ID:NIC_ID pairs, control traffic direction with DIRECTION (IN, OUT, or BOTH, the default), and optionally filter traffic with VLANS.

Configure RSPAN destinations with OUTPUT_VLAN, and GRE or ERSPAN destinations with REMOTE_IP and optional LOCAL_IP. The local address accepts either an IPv4 address or an interface:<name> reference resolved on each host. ERSPAN adds ERSPAN_TYPE and ERSPAN_KEY, with ERSPAN_INDEX for type II and ERSPAN_HWID for type III. Validate required fields, numeric ranges, and incompatible attribute combinations.

Expose mirror creation, configuration updates, source-port membership changes, and deletion through XML-RPC and gRPC, with Ruby, Java, and Go client support and corresponding onevnet mirror-* commands. Add a Sunstone Port Mirroring tab with creation and editing forms, source-interface selection, configuration review, and mirror details. Require administrative permissions on the Virtual Network and selected source VMs; manage definitions through the dedicated mirror APIs.

Integrate mirror configuration with VM networking operations so host OVS state follows NIC activation, updates, and deactivation, and released NICs are removed from mirror membership. Serialize shared mirror changes under a host lock, apply OVS updates in a single transaction, and clean up unused managed tunnel outputs. Configuration updates preserve source membership, membership changes target affected VMs, and mirrors must have all source ports removed before deletion.

co-authored-by: Alejandro Aizel <aaizel@opennebula.io>
co-authored-by: Daniel Clavijo Coca <dclavijo@opennebula.io>
co-authored-by: Pavel Czerny <pczerny@opennebula.io>
co-authored-by: David Carracedo <dcarracedo@opennebula.io>
2026-11-03 14:04:07 +01:00

1075 lines
31 KiB
Plaintext
Executable File

# -------------------------------------------------------------------------- #
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# shellcheck disable=SC2148
# shellcheck disable=SC2207
COL_NAME="name"
################################################################################
# Helpers
################################################################################
# 1 -> cmd
# 2 -> column
# 3 -> filter
_complete() {
mapfile -t patterns < <( _one_list "$1" "$2" "$3" )
mapfile -t COMPREPLY < <( compgen -W "$( printf '%q ' "${patterns[@]}" )" -- "$cur")
compopt -o filenames
}
# Complete file paths matching the prefix in $1. Read one candidate per line
# to preserve spaces and avoid glob expansion. Tell Readline to quote filenames
# and append a slash to directories so completion can continue inside them.
_one_complete_files() {
mapfile -t COMPREPLY < <(compgen -A file -- "$1")
compopt -o filenames
}
_one_list() {
if [ -z "$2" ]; then
col="$COL_NAME"
else
col=$2
fi
if [ -n "$3" ]; then
$1 list --no-header --csv -f "$3" -l "$col"
else
$1 list --no-header --csv -l "$col"
fi
}
_one_simple() {
local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${1}" -- "${cur}") )
return 0
fi
}
_one_owner_update() {
case "$1" in
chgrp)
_complete onegroup
;;
chown)
_complete oneuser
;;
update)
_one_complete_files "$cur"
return 0
;;
esac
}
_one_template() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|instantiate|chgrp|chown|chmod|update|rename|show|lock|unlock)
_complete "$cmd"
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
################################################################################
# Services
################################################################################
_one() {
_one_simple "start stop restart start-sched stop-sched restart-sched"
}
_oneflow_server() {
_one_simple "start stop"
}
_oneform_server() {
_one_simple "start stop"
}
_onehem_server() {
_one_simple "start stop"
}
_onegate_server() {
_one_simple "start stop restart"
}
_sunstone_server() {
_one_simple "start stop restart start-sunstone stop-sunstone restart-sunstone"
}
complete -F _one one
complete -F _oneflow_server oneflow-server
complete -F _oneform_server oneform-server
complete -F _onehem_server onehem-server
complete -F _onegate_server onegate-server
complete -F _sunstone_server sunstone-server
################################################################################
# Commands
################################################################################
_oneacl() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="create delete list"
cmd=oneacl
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete)
_complete $cmd
;;
esac
fi
}
_onebackupjob() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show lock unlock chgrp chown chmod rename
update backup cancel retry priority sched-delete sched-update"
cmd=onebackupjob
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|lock|unlock|chgrp|chown|chmod|rename| \
update|backup|cancel|retry|priority|sched-update|sched-delete)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onecluster() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show addhost delhost adddatastore deldatastore
addvnet delvnet update rename optimize planexecute plandelete"
cmd=onecluster
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|addhost|delhost|adddatastore|deldatastore|addvnet| \
delvnet|update|rename|optimize|planexecute|plandelete)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addhost|delhost)
_complete onehost
;;
adddatastore|deldatastore)
_complete onedatastore
;;
addvnet|delvnet)
_complete onevnet
;;
update)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_onedatastore() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete chgrp chown chmod list show update rename enable disable"
cmd=onedatastore
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|chgrp|chown|chmod|show|update|rename|enable|disable)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onedb() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="backup version history restore upgrade fsck patch
sqlite2mysql purge-history purge-done change-body change-history
update-body update-history show-body show-history create-index"
cmd=onedb
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
restore|patch)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_oneflow() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="list top show delete recover scale chgrp chown chmod rename action
sched-delete update purge-done add-role remove-role release"
cmd=oneflow
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|delete|recover|scale|chgrp|chown|chmod|rename|action| \
sched-delete|update|add-role|remove-role|release)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
add-role)
_one_complete_files "$cur"
return 0
;;
*)
_one_owner_update "$pprev"
;;
esac
fi
}
_oneflow_template() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="list top show create delete instantiate chgrp chown chmod clone rename update"
cmd=oneflow-template
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|delete|instantiate|chgrp|chown|chmod|clone|rename|update)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onegroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update delete list show addadmin deladmin quota batchquota
defaultquota vlan"
cmd=onegroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|delete|show|addadmin|deladmin|quota|batchquota|vlan)
_complete $cmd
;;
defaultquota)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addadmin|deladmin)
_complete oneuser
;;
update|quota|batchquota|vlan)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_onehook() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete update rename list show top lock unlock retry log"
cmd=onehook
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|update|rename|show|lock|unlock|retry)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_onehost() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete enable disable offline update sync list show top flush
rename forceupdate monitoring"
cmd=onehost
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|disable|offline|update|sync|show|flush|rename| \
forceupdate|monitoring)
_complete $cmd
;;
enable)
mapfile -t patterns < <( onehost list -f "stat=off,stat=dsbl" --operator OR --no-header --csv -l $COL_NAME )
mapfile -t COMPREPLY < <( compgen -W "$( printf '%q ' "${patterns[@]}" )" -- "$cur")
compopt -o filenames
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_oneimage() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create clone delete persistent nonpersistent update enable chtype
disable chgrp chown chmod rename snapshot-delete snapshot-revert
snapshot-flatten list show top lock unlock orphans restore"
cmd=oneimage
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|persistent|nonpersistent|update|chtype|chgrp|chown|chmod| \
rename|snapshot-delete|snapshot-revert|snapshot-flatten|show|lock|unlock)
_complete $cmd
;;
enable)
_complete $cmd $COL_NAME "stat=disa"
;;
disable)
_complete $cmd $COL_NAME "stat=rdy"
;;
restore)
_complete $cmd $COL_NAME "type=BK"
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onemarket() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete chgrp chown chmod list show update rename enable disable"
cmd=onemarket
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|chgrp|chown|chmod|show|update|rename)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onemarketapp() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create export delete update chgrp chown chmod rename list show enable
disable lock unlock"
cmd=onemarketapp
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
export|delete|update|chgrp|chown|chmod|rename|show|lock|unlock)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
enable)
_complete $cmd $COL_NAME "stat=dis"
;;
disable)
_complete $cmd $COL_NAME "stat=rdy"
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_oneform()
{
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneform
opts="list top show sync enable disable"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|enable|disable)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_oneprovision() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneprovision
opts="list top show create update rename chgrp chown chmod retry add-host del-host add-ip del-ip deprovision delete logs"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|update|rename|chgrp|chown|chmod|delete|retry)
_complete $cmd ID
;;
create)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_oneprovider() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneprovider
opts="list top show create update rename chgrp chown chmod delete"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|update|rename|chgrp|chown|chmod|delete)
_complete $cmd ID
;;
create)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_oneks()
{
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
cmd=oneks
opts="list top show create update rename chgrp chown chmod retry delete logs"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|update|rename|chgrp|chown|chmod|retry|delete|logs)
_complete $cmd ID
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
create)
_one_complete_files "$cur"
return 0
;;
*)
_one_owner_update "$pprev"
esac
fi
}
_onesecgroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create clone delete chgrp chown chmod update rename commit list show"
cmd=onesecgroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|chgrp|chown|chmod|update|rename|commit|show)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_oneshowback() {
local opts
opts="list calculate"
_one_simple "$opts"
}
_onetemplate() {
opts="create clone delete instantiate chgrp chown chmod update rename list show
top lock unlock"
cmd=onetemplate
_one_template
}
_oneuser() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update quota batchquota defaultquota umask login key delete
passwd chgrp addgroup delgroup chauth list show encode passwdsearch
token-create token-set token-delete token-delete-all enable disable"
cmd=oneuser
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|quota|batchquota|umask|delete|passwd|chgrp|addgroup| \
delgroup|chauth|show|enable|disable)
_complete $cmd
;;
defaultquota)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
chgrp|addgroup|delgroup)
_complete onegroup
;;
update|quota|batchquota)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_onevdc() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create rename update delete addgroup delgroup addcluster delcluster
addhost delhost adddatastore deldatastore addvnet delvnet list show"
cmd=onevdc
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
rename|update|delete|addgroup|delgroup|addcluster|delcluster|addhost| \
delhost|adddatastore|deldatastore|addvnet|delvnet)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addgroup|delgroup)
_complete onegroup
;;
addcluster|delcluster)
_complete onecluster
;;
addhost|delhost)
_complete onehost
;;
adddatastore|deldatastore)
_complete onedatastore
;;
addvnet|delvnet)
_complete onevnet
;;
update)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
_onevm() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update hold release disk-saveas terminate undeploy poweroff
reboot deploy migrate stop suspend resume recover disk-attach
disk-detach nic-attach nic-detach nic-update sg-attach sg-detach
chgrp chown chmod resched unresched rename snapshot-create
snapshot-revert snapshot-delete snapshot-list disk-snapshot-create
disk-snapshot-revert disk-snapshot-delete disk-snapshot-rename
disk-snapshot-list disk-resize list show top resize save backupmode
updateconf lock unlock exec exec-retry exec-cancel create-chart
delete-chart update-chart sched-delete sched-update backup
backup-cancel pci-attach pci-detach ssh port-forward vnc restore
vmgroup-add vmgroup-del"
cmd=onevm
if [ "$COMP_CWORD" -gt 1 ]; then
case "${COMP_WORDS[1]}" in
hold|release|terminate|undeploy|poweroff|reboot|stop|suspend|resume| \
snapshot-create|snapshot-revert|snapshot-delete|disk-snapshot-create| \
disk-snapshot-revert|disk-snapshot-delete|backup)
case "$prev" in
--schedule|--weekly|--monthly|--yearly|--hourly|--end)
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W "--schedule --weekly --monthly
--yearly --hourly --end" -- "${cur}") )
return 0
fi
;;
esac
fi
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|hold|release|disk-saveas|terminate|show|resume|recover| \
disk-attach|disk-detach|nic-attach|nic-detach|nic-update|sg-attach| \
sg-detach|chgrp|chown|chmod|resched|unresched|rename|snapshot-create| \
snapshot-revert|snapshot-delete|snapshot-list|disk-snapshot-create| \
disk-snapshot-delete|disk-snapshot-revert|disk-snapshot-rename| \
disk-snapshot-list|disk-resize|save|backupmode|updateconf|lock|unlock| \
exec|exec-retry|exec-cancel|create-chart|delete-chart|update-chart| \
sched-delete|sched-update|backup|backup-cancel|pci-attach|pci-detach| \
restore|ssh|port-forward|vnc|vmgroup-add|vmgroup-del)
_complete $cmd
;;
undeploy|poweroff|reboot|suspend|stop|migrate)
_complete $cmd $COL_NAME "stat=runn"
;;
deploy)
_complete $cmd $COL_NAME "stat=pend"
;;
resize)
_complete $cmd $COL_NAME "stat=poff"
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
deploy|migrate)
_complete onehost $COL_NAME "stat=on"
;;
restore)
_complete oneimage $COL_NAME "type=BK"
;;
vmgroup-add)
_complete onevmgroup
;;
esac
_one_owner_update "$pprev"
elif [ "$COMP_CWORD" == 4 ]; then
case "${COMP_WORDS[1]}" in
sched-update|update-chart)
_one_complete_files "$cur"
;;
esac
fi
}
_onevmgroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show chgrp chown chmod update rename lock unlock
role-add role-delete role-update"
cmd=onevmgroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|chgrp|chown|chmod|update|rename|lock|unlock| \
role-add|role-delete|role-update)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
role-add)
_one_complete_files "$cur"
return 0
;;
*)
_one_owner_update "$pprev"
;;
esac
fi
}
_onevnet() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete addar rmar free hold release reserve chgrp chown chmod
list show update updatear rename lock unlock orphans recover
mirror-create mirror-update mirror-addport mirror-delport
mirror-delete"
cmd=onevnet
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|addar|rmar|free|hold|release|reserve|recover|chgrp| \
chown|chmod|show|update|updatear|rename|lock|unlock|mirror-create| \
mirror-update|mirror-addport|mirror-delport|mirror-delete)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addar|update|mirror-create)
_one_complete_files "$cur"
return 0
;;
reserve)
_complete onevnet
;;
esac
_one_owner_update "$pprev"
elif [ "$COMP_CWORD" == 4 ]; then
case "${COMP_WORDS[1]}" in
mirror-update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onevntemplate() {
local opts cmd
opts="create clone delete instantiate chgrp chown chmod update rename list show
top lock unlock"
cmd=onevntemplate
_one_template
}
_onevrouter() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create instantiate delete chgrp chown chmod update rename nic-attach
nic-detach list show top lock unlock"
cmd=onevrouter
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
instantiate|delete|chgrp|chown|chmod|update|rename|nic-attach| \
nic-detach|show|lock|unlock)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onezone() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create rename server-add server-del server-reset update delete list
show set serversync enable disable"
cmd=onezone
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
rename|server-add|server-del|server-reset|update|delete|show|set| \
enable|disable)
_complete $cmd
;;
create)
_one_complete_files "$cur"
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
_one_complete_files "$cur"
return 0
;;
esac
fi
}
complete -F _oneacl oneacl
complete -F _onebackupjob onebackupjob
complete -F _onecluster onecluster
complete -F _onedatastore onedatastore
complete -F _onedb onedb
complete -F _oneflow oneflow
complete -F _oneflow_template oneflow-template
complete -F _onegroup onegroup
complete -F _onehook onehook
complete -F _onehost onehost
complete -F _oneimage oneimage
complete -F _onemarket onemarket
complete -F _onemarketapp onemarketapp
complete -F _oneform oneform
complete -F _oneprovision oneprovision
complete -F _oneprovider oneprovider
complete -F _oneks oneks
complete -F _onesecgroup onesecgroup
complete -F _oneshowback oneshowback
complete -F _onetemplate onetemplate
complete -F _oneuser oneuser
complete -F _onevdc onevdc
complete -F _onevm onevm
complete -F _onevmgroup onevmgroup
complete -F _onevnet onevnet
complete -F _onevntemplate onevntemplate
complete -F _onevrouter onevrouter
complete -F _onezone onezone