astratto/vcloud-rest — pull request #22 by brettswift (2014-01-02 20:05:05+00:00)
Title: vm snapshot capability

Hey @astratto,

The API documentation is very obscure about this, but you can actually snapshot a VM. It's just unintuitive because your request is sent to the ./vapp/ URI. You do a ./vapp/vm-{id}/action..... for vm's and ./vapp/vapp-{id} for vm's.

Because of this behaviour, I pulled the snapshot behaviour out of vapp, and into connection.rb. I kept the old method, but the old vapp method is now commented as deprecated, and delegates to the connection.rb.

vapp/create_snapshot(id) --> connection/create_vapp_snapshot(id, :vapp)
vapp/create_vapp_snapshot(id) --> connection/create_vapp_snapshot(id, :vapp)
vm/create_vm_snapshot(id) --> connection/create_vm_snapshot(id, :vm)

As you can see I used the same pattern you had for the power_actions common method.

I want to include mocha, and do an assertion unit test for when create_snapshot_action (couldn't come up with a better name) is called that the :type property is being used properly. So I can put that in before this PR is merged.

Please comment on implementation - if you'd rather see it implemented a different way - I'd be interested to hear!

Thanks!