nsidc/vagrant-vsphere — pull request #93 by rylarson (2014-09-21 17:26:13+00:00)
Title: Make destroy work in all vm states

* If the VM is powered on, then it is powered off, and destroyed.
* If the VM is powered off, it is just destroyed.
* If the VM is suspended, it is powered on, then powered off, then destroyed.
* This feels weird, but the vsphere API docs state that calling power off on a vm in any other state besides poweredOn will throw an exception.
* Also, the Destroy_Task documentation and the VirtualMachine documentation don't specify what state the VM has to be in before it is destroyed.
-Since the current implementation tries to make sure it is powered off before it is destroyed, I am making sure to do the same if the VM is suspended.

== DETAILS

* I refactored the VM state stuff into a common module called VmHelpers. The get_state action now uses this for getting the machine state, and most of the common vm tasks
are wrapped by this class.
* Basically what we are doing here is making the power_off action idempotent, and I toyed with the idea of making idempotent wrapper methods in VmHelpers, but decided that
VmHelpers should just deal with interacting with the VM and let the actions themselves enforce idempotency if they wish.

== ISSUES

This should fix the following issue: https://github.com/nsidc/vagrant-vsphere/issues/77