Added createvm command

This commit is contained in:
2015-04-09 19:51:25 +02:00
parent 878b1e6b01
commit 6a64c2b8ce
2 changed files with 46 additions and 1 deletions

1
README
View File

@@ -15,6 +15,7 @@ Current version of script was written and tested against VBoxManage in version
- controlvm - controlvm
- convertfromraw - convertfromraw
- createhd - createhd
- createvm
- list - list
- showhdinfo - showhdinfo
- showvminfo - showvminfo

View File

@@ -16,7 +16,7 @@
# [x] controlvm # [x] controlvm
# [x] convertfromraw # [x] convertfromraw
# [x] createhd # [x] createhd
# [ ] createvm # [x] createvm
# [ ] debugvm # [ ] debugvm
# [ ] dhcpserver # [ ] dhcpserver
# [ ] discardstate # [ ] discardstate
@@ -145,6 +145,7 @@ _VBoxManage() {
sed 's/|/ /g') sed 's/|/ /g')
COMPREPLY=( $(compgen -W "$list" -- ${cur}) ) COMPREPLY=( $(compgen -W "$list" -- ${cur}) )
} }
_group_comp() { _group_comp() {
local cur=$1 local cur=$1
local list local list
@@ -163,6 +164,24 @@ _VBoxManage() {
done done
} }
_os_comp() {
local cur=$1
local list
local item
list=$(VBoxManage list ostypes | \
egrep ^ID: | \
sed 's/ID:\s\+//' | \
tr '\n' '|' | \
sed 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
do
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
done
}
# Check the COMP_WORDS looking for name of the vm. If name contain space or # Check the COMP_WORDS looking for name of the vm. If name contain space or
# is enclosed in quotes, glue name together in variable name. Variable index # is enclosed in quotes, glue name together in variable name. Variable index
# will hold the last index of COMP_WORDS array which contain the end of the # will hold the last index of COMP_WORDS array which contain the end of the
@@ -582,6 +601,31 @@ _VBoxManage() {
fi fi
;; ;;
createvm) createvm)
items=(--name --groups --ostype --register --basefolder --uuid)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
else
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--groups)
COMPREPLY=()
_group_comp ${cur}
;;
--ostype)
COMPREPLY=()
_os_comp ${cur}
;;
--basefolder)
COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
;;
--variant)
COMPREPLY=( $(compgen -W "Standard Fixed Split2G Stream
ESX" -- ${cur}) )
;;
esac
fi
;; ;;
debugvm) debugvm)
;; ;;