Skip to content

Instantly share code, notes, and snippets.

@ljjjustin
Created June 27, 2019 06:11
Show Gist options
  • Save ljjjustin/3c29672561c99e06a196fa925df9821f to your computer and use it in GitHub Desktop.
Save ljjjustin/3c29672561c99e06a196fa925df9821f to your computer and use it in GitHub Desktop.
migrate vm in openstack env
#!/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