Merge "improve migration script"

This commit is contained in:
Zuul 2018-08-13 04:05:31 +00:00 committed by Gerrit Code Review
commit 16f89fd093
1 changed files with 18 additions and 19 deletions

View File

@ -35,31 +35,30 @@ nodes. For more information, see :ref:`cli-os-migrate-cfg-ssh`.
# Provide usage
usage() {
echo "Usage: $0 VM_ID"
exit 1
echo "Usage: $0 VM_ID"
exit 1
}
[[ $# -eq 0 ]] && usage
# Migrate the VM to an alternate hypervisor
echo -n "Migrating instance to alternate host"
VM_ID=$1
openstack server migrate $VM_ID
VM_OUTPUT=$(openstack server show $VM_ID)
VM_STATUS=$(echo "$VM_OUTPUT" | grep status | awk '{print $4}')
while [[ "$VM_STATUS" != "VERIFY_RESIZE" ]]; do
echo -n "."
sleep 2
VM_OUTPUT=$(openstack server show $VM_ID)
VM_STATUS=$(echo "$VM_OUTPUT" | grep status | awk '{print $4}')
done
openstack server resize --confirm $VM_ID
echo " instance migrated and resized."
echo;
# Show the details for the VM
echo "Updated instance details:"
openstack server show $VM_ID
echo "Instance details:"
openstack server show ${VM_ID}
# Migrate the VM to an alternate hypervisor
echo -n "Migrating instance to alternate host "
openstack server migrate ${VM_ID}
while [[ "$(openstack server show ${VM_ID} -f value -c status)" != "VERIFY_RESIZE" ]]; do
echo -n "."
sleep 2
done
openstack server resize --confirm ${VM_ID}
echo " instance migrated and resized."
# Show the details for the migrated VM
echo "Migrated instance details:"
openstack server show ${VM_ID}
# Pause to allow users to examine VM details
read -p "Pausing, press <enter> to exit."