chef-boneyard / chef-provisioning-vsphere

DEPRECATED: A chef-provisioning provisioner for VMware vSphere
MIT License
17 stars 15 forks source link

Action :destroy fails on powered off VM #59

Closed algaut closed 7 years ago

algaut commented 7 years ago

Hello every one, I had some trouble with the :destroy action:

Versions:

Platform Details

Scenario:

Trying to delete some virtual machines after a failed deployment. The VM where just cloned from a template and never powered on (that's an other problem), but the destroy action fails.

Steps to Reproduce:

Try to destroy a powered off VM that was deployed with chef provisioning

Expected Result:

The VM is destroyed

Actual Result:

The chef-client run fails.

The error I get: RbVmomi::Fault: InvalidPowerState: The attempted operation cannot be performed in the current state (Powered off) Seems that the gem is trying to power off the VM before deleting it, but doesn't rescue the RbVmomi error saying it's already off.

Possible resolution

Either catch the exception in the destroy action, or in the stop_vm function, or check that the VM is not off before trying to stop it.