Correct search of name virtual machines in list
In the functions is_vm_running() and is_vm_present(), located in the file function/vm.sh, search of running and available virtual machines has been fixed. The search of the names virtual machines extrafuel-master and extrafuel-slave-1 didn't work correctly. Change-Id: If73546e5b4b2a8a64f0b955f85579ee0dafd93f0 Closes-Bug: #1387602
This commit is contained in:
parent
7bc336a326
commit
057b95e3ef
|
@ -33,22 +33,24 @@ is_vm_running() {
|
|||
list=$(get_vms_running)
|
||||
|
||||
# Check that the list of running VMs contains the given VM
|
||||
if [[ $list = *$name* ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
for name_in_list in $list; do
|
||||
if [[ "$name_in_list" == "$name" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
is_vm_present() {
|
||||
name=$1
|
||||
list=$(get_vms_present)
|
||||
|
||||
if [[ $list = *$name* ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
for name_in_list in $list; do
|
||||
if [[ "$name_in_list" == "$name" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
create_vm() {
|
||||
|
@ -129,9 +131,18 @@ delete_vm() {
|
|||
vm_path="$vm_base_path/$name/"
|
||||
|
||||
# Power off VM, if it's running
|
||||
if is_vm_running $name; then
|
||||
count=0
|
||||
while is_vm_running $name; do
|
||||
echo "Stopping Virtual Machine $name..."
|
||||
VBoxManage controlvm $name poweroff
|
||||
fi
|
||||
if [[ "$count" != 5 ]]; then
|
||||
count=$((count+1))
|
||||
sleep 5
|
||||
else
|
||||
echo "VirtualBox cannot stop VM $name... Exiting"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Deleting existing virtual machine $name..."
|
||||
while is_vm_present $name
|
||||
|
|
Loading…
Reference in New Issue