I've been pouring through the documents and example for the official VMWare pyvmomi API and for the life of me I cannot find an obvious way to just nuke a VM off of an ESXi server.
Can anyone provide an example or point me to someone who has implmented this already - it seems like the only alternative is to roll something myself that would
I think each part is there but I really hope someone could point me in the right direction.
I will be glad to help with this. First off you are correct in that you have to do the steps. They would be locate the VM, next power it off, and finally destroy the VM. The destroy task will remove the files and remove from inventory.
I have created a sample script to show you what to do. This has been tested in 4.1, 5.0, and 5.5 vSphere. https://github.com/virtdevninja/pyvmomi-community-samples/blob/master/samples/destroy_vm.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With