mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
M #-: Remove old/duplicate bash compl. file (#96)
(cherry picked from commit c92c8a8bb19e9b4846460c10b03c1f81275874ab)
This commit is contained in:
parent
0960e83ff3
commit
75b95189df
@ -1,156 +0,0 @@
|
||||
_one_list() {
|
||||
local cmd filter
|
||||
one_cmd=$1
|
||||
if [ -n "$2" ]; then
|
||||
filter="-f $2"
|
||||
fi
|
||||
echo $($one_cmd $filter list|sed 1d|awk '{print $1}')
|
||||
return 0
|
||||
}
|
||||
|
||||
_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 deploy shutdown livemigrate migrate hold release stop cancel suspend resume delete restart list show top history"
|
||||
cmd=onevm
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
elif [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
show|delete)
|
||||
vms=`_one_list $cmd`
|
||||
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
cancel|shutdown|suspend|stop)
|
||||
vms=`_one_list $cmd stat='runn'`
|
||||
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
create|submit)
|
||||
COMPREPLY=( $(compgen -A file -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
migrate)
|
||||
vms=`_one_list $cmd stat='runn'`
|
||||
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
elif [ $COMP_CWORD == 3 ]
|
||||
then
|
||||
case "$pprev" in
|
||||
migrate)
|
||||
hosts=`onehost list -f STAT=on|sed 1d|awk '{print $2}'`
|
||||
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _onevm onevm
|
||||
|
||||
_onevnet() {
|
||||
local cur prev opts cmd
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="create delete list show"
|
||||
cmd=onevnet
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
elif [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
create|submit)
|
||||
COMPREPLY=( $(compgen -A file -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
delete|show)
|
||||
vnets=`_one_list $cmd`
|
||||
COMPREPLY=( $(compgen -W "${vnets}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
complete -F _onevnet onevnet
|
||||
|
||||
_onehost() {
|
||||
local cur prev opts cmd
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="create show delete list enable disable top"
|
||||
cmd=onehost
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
elif [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
create|submit)
|
||||
COMPREPLY=( $(compgen -A file -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
delete|show)
|
||||
hosts=`_one_list $cmd`
|
||||
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
enable)
|
||||
hosts=`_one_list $cmd stat='off'`
|
||||
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
disable)
|
||||
hosts=`_one_list $cmd stat='on'`
|
||||
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
complete -F _onehost onehost
|
||||
|
||||
_onetemplate() {
|
||||
local cur prev opts cmd
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="create clone delete instantiate chgrp chown chmod "
|
||||
opts+="update rename list show top lock unlock"
|
||||
cmd=onetemplate
|
||||
if [ $COMP_CWORD == 1 ]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
elif [ $COMP_CWORD == 2 ]
|
||||
then
|
||||
case "$prev" in
|
||||
create)
|
||||
COMPREPLY=( $(compgen -A file -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
complete -F _onetemplate onetemplate
|
Loading…
x
Reference in New Issue
Block a user