CenturyLinkCloud / chef-provisioning-vsphere

A chef-provisioning provisioner for VMware vSphere
MIT License
66 stars 57 forks source link

Ability to kitchen destroy powered off VM #106

Open martinmosegaard opened 7 years ago

martinmosegaard commented 7 years ago

I ran a kitchen command to destroy a VM like so:

set KITCHEN_YAML=.kitchen.vsphere.yml && kitchen destroy

with an error message:

>>>>>>     Failed to complete #destroy action: [InvalidPowerState: 
The attempted operation cannot be performed in the current state (Powered off).] 
on name-of-the-vm

It seemed to fail trying to power off a VM that was already powered off (I am guessing, I don't have the logs). I am not sure why it happened. But in any case, if someone outside powered off the VM, it would be great if the script would just continue to destroy the VM in case it was already powered off.

Should be rather simple to fix: Before doing a power off operation, check if vm.summary.runtime.powerState is poweredOff.

I will be happy to take a look at some point.