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)
|
list=$(get_vms_running)
|
||||||
|
|
||||||
# Check that the list of running VMs contains the given VM
|
# Check that the list of running VMs contains the given VM
|
||||||
if [[ $list = *$name* ]]; then
|
for name_in_list in $list; do
|
||||||
|
if [[ "$name_in_list" == "$name" ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
is_vm_present() {
|
is_vm_present() {
|
||||||
name=$1
|
name=$1
|
||||||
list=$(get_vms_present)
|
list=$(get_vms_present)
|
||||||
|
|
||||||
if [[ $list = *$name* ]]; then
|
for name_in_list in $list; do
|
||||||
|
if [[ "$name_in_list" == "$name" ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
create_vm() {
|
create_vm() {
|
||||||
|
@ -129,9 +131,18 @@ delete_vm() {
|
||||||
vm_path="$vm_base_path/$name/"
|
vm_path="$vm_base_path/$name/"
|
||||||
|
|
||||||
# Power off VM, if it's running
|
# 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
|
VBoxManage controlvm $name poweroff
|
||||||
|
if [[ "$count" != 5 ]]; then
|
||||||
|
count=$((count+1))
|
||||||
|
sleep 5
|
||||||
|
else
|
||||||
|
echo "VirtualBox cannot stop VM $name... Exiting"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Deleting existing virtual machine $name..."
|
echo "Deleting existing virtual machine $name..."
|
||||||
while is_vm_present $name
|
while is_vm_present $name
|
||||||
|
|
Loading…
Reference in New Issue