Evacuating instances on a compute hardware failure
The snippet can be accessed without any authentication.
Authored by
Kenneth Peeples
Evacuating a whole compute node failed for us so evacuated each instance
# Pass in the hypervisor to get the list of instances
# Sometimes a whole compute node evacuate may fail
if [[ -z $1 ]]; then
echo "Pass in a hypervisor, such as compute018.bbh.cyberschool.army.mil"
exit
fi
nova hypervisor-servers $1 > /tmp/hypervisorinstances
while read line; do
instanceUUID=`echo $line | cut -d'|' -f2`
# Only get the Server UUIDs and ignore the header lines, could change to a regex check
if [[ `echo $instanceUUID | wc -c` -eq 37 ]]; then
echo "=================================> instance - $instanceUUID"
# depending on the state of the instance only evacuate maybe required
# Ran it without reset-state first which gets active
# nova reset-state --active $instanceUUID
nova evacuate $instanceUUID
# Reboot can be used if there are issues not starting on the new compute
# nova reboot --hard $instanceUUID
openstack server show $instanceUUID
echo "==========================================================="
fi
done < /tmp/hypervisorinstances
Please register or sign in to comment