NOTE: This is old, I have been working on new scripts for Rundeck, one of the scripts is meant to do this same operation but for Icehouse.
I recommend you take a look at it. This script might work still, but I have not tested it against any of the newer releases of OpenStack, I believe it was written against Essex.
This is a script I use to remove instances from the OpenStack database when things go bad.
The script is fairly straight forward, you pass it an instance name, it looks it up in the DB to get the ID and UUID, then removes it from the tables.
If you go this route, you will need to use virsh to shutdown and undefine the instance and manually remove the instance data from the file system.
If using Quantum/OVS then you will need to also find the network ports (quantum port-list) and remove them also (port-delete).
#!/bin/bash # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # <http://www.gnu.org/licenses/>. # VMNAME=$1 if [ -z "$1" ]; then echo "VM Name not given"; exit 1; fi Q=`cat <<EOF SELECT id FROM nova.instances WHERE instances.display_name = '$VMNAME'; SELECT uuid FROM nova.instances WHERE instances.display_name = '$VMNAME'; EOF` RQ=`mysql --batch --skip-column-names -e "$Q"` ID=`echo $RQ | cut -d' ' -f1` UUID=`echo $RQ | cut -d' ' -f2` if [ -z "$ID" ]; then echo "ID for $VNAME not found"; exit 1; fi if [ -z "$UUID" ]; then echo "UUID for $VNAME not found"; exit 1; fi echo "VMNAME: $VMNAME" echo "ID: $ID" echo "UUID: $UUID" echo "Delete $VMNAME? (y/n)" read -e YN if [ "$YN" != 'y' ]; then echo "Exiting...";exit 1;fi Q=`cat <<EOF DELETE FROM nova.instance_faults WHERE instance_faults.instance_uuid = '$UUID'; DELETE FROM nova.instance_id_mappings WHERE instance_id_mappings.uuid = '$UUID'; DELETE FROM nova.instance_info_caches WHERE instance_info_caches.instance_uuid = '$UUID'; DELETE FROM nova.instance_system_metadata WHERE instance_system_metadata.instance_uuid = '$UUID'; DELETE FROM nova.security_group_instance_association WHERE security_group_instance_association.instance_uuid = '$UUID'; DELETE FROM nova.instances WHERE instances.uuid = '$UUID'; EOF` RQ=`mysql --batch --skip-column-names -e "$Q"` echo "$RQ"