# 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