Created
June 27, 2019 06:11
-
-
Save ljjjustin/3c29672561c99e06a196fa925df9821f to your computer and use it in GitHub Desktop.
migrate vm in openstack env
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 | |
if [ $# -ne 1 ]; then | |
echo "usage: $0 <vm uuid or name>" | |
exit | |
fi | |
vm=$1 | |
wait_status() { | |
local target=$1 | |
while true | |
do | |
status=$(nova show ${vm} | grep -w status | awk '{print $4}' | awk '{print tolower($0)}') | |
if [ "${target}" = "${status}" ]; then | |
break | |
fi | |
sleep 3 | |
done | |
} | |
nova stop ${vm} | |
wait_status shutoff | |
nova migrate ${vm} | |
wait_status verify_resize | |
nova resize-confirm ${vm} | |
wait_status shutoff | |
nova start ${vm} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment