/etc/bash_completion.d/one is in opennebula 3.4.1-4.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | _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
|