Skip to content

Instantly share code, notes, and snippets.

@vnugent
Last active December 29, 2015 11:59
Show Gist options
  • Save vnugent/7667617 to your computer and use it in GitHub Desktop.
Save vnugent/7667617 to your computer and use it in GitHub Desktop.
force clean rhev VMs
select vms.vm_guid into temp bad_vms from vms where status=8;
select device_id into temp bad_vm_devices from vm_device where type='disk' and device='disk' and vm_id in (select vm_guid from bad_vms);
delete from vm_device where vm_id in (select vm_guid from bad_vms);
delete from vm_statistics where vm_guid in (select vm_guid from bad_vms);
delete from snapshots where vm_id in (select vm_guid from bad_vms);
delete from vm_static where vm_guid in (select vm_guid from bad_vms);
delete from vm_interface where vm_guid in (select vm_guid from bad_vms);
delete from vm_interface_statistics where vm_id in (select vm_guid from bad_vms);
delete from vm_dynamic where vm_guid in (select vm_guid from bad_vms);
delete from tags_vm_map where vm_id in (select vm_guid from bad_vms);
delete from vm_pool_map where vm_guid in (select vm_guid from bad_vms);
delete from base_disks where disk_id in (select device_id from bad_vm_devices);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment