Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make destroy work in all vm states #93

Merged
merged 3 commits into from Sep 23, 2014

Conversation

rylarson
Copy link
Contributor

  • 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: #77

== TESTING

All specs pass, and created new power_off_spec to test calling power off in all 3 states does the correct thing.

Ryan Larson added 3 commits September 20, 2014 23:08
-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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants