-
Notifications
You must be signed in to change notification settings - Fork 9
/
instance-delete.txt
40 lines (35 loc) · 1.83 KB
/
instance-delete.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Delete OpenStack Nova Instance manually
#
# Only consider doing this when normal commands have failed
#
# https://raymii.org/s/articles/Fix_inconsistent_Openstack_volumes_and_instances_from_Cinder_and_Nova_via_the_database.html
#
# NOTE:
# Nothing in here should be done unless normal API calls have failed !!
#
# Make sure any cinder volumes have been detached first
# Cleanup related fixed and floating IPs
# Check block_device_mappings
# Detach cinder volumes
nova volume-detach $vm_uuid $volume_uuid
# if fails and it is detached in cinder. Verify actual storage!!!
mysql -e "update cinder.volumes set attach_status='detached',status='available' where id ='$volume_uuid';"
mysql nova
# Set deleted flags instead: deleted_at, deleted,
#delete from block_device_mapping where not deleted and volume_id='$volume_uuid' and project_id='$project_uuid';
update block_device_mapping set deleted_at=now(),updated_at=now(),deleted= where not deleted and instance_uuid='$instance_uuid';
Instance Deletion:
- Connect to the nova database and update the instance information:
# ID=$(mysql -e "select id from nova.instances where uuid='<instance-uuid>';" | egrep '[0-9]{1,5}')
# mysql -e "update nova.instances set updated_at=now(),deleted_at=now(),terminated_at=now(),vm_state='deleted',task_state=NULL,deleted='1' where uuid='<instance uuid>';"
# you may also need to update the nova.fixed_ips table and the nova.floating_ips table
- ssh to the hosting hypervisor
- destroy the instance
- get the instance id from libvirt.xml
# grep "<name>instance" /var/lib/nova/instances/e621cbc8-0ab2-4d72-8c48-2b48fb7f9908/libvirt.xml
# /var/lib/nova/instances/<Nova instance UUID>
- destroy and undefine the instance
# virsh destroy instance-XXXXXXXX
# virsh undefine instance-XXXXXXXX
- delete the instance directory
# rm -rf /var/lib/nova/instances/<instance uuid>