Created
August 10, 2018 15:46
-
-
Save furlongm/55eb018a6ee7e7587f3f60a75457f2a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Provide usage | |
usage() { | |
echo "Usage: $0 VM_ID" | |
exit 1 | |
} | |
[[ $# -eq 0 ]] && usage | |
VM_ID=$1 | |
# Show the details for the VM | |
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment