This massive commit refactors all of the request methods on the
Fog::Compute[:vsphere] instance to return simple hashes. The behavior
before this commit returned full vmware object references which was a
problem because it was difficult to unit test.
With this patch, it is much easier to add and maintain Mock
implementations of the request methods. This makes adding behavior
tests for the server model much easier.
In addition, test coverage using Shindo has been added. Previously
there was little test coverage of the behavior.
To run the tests:
shindont tests/vsphere/
Without this patch it is very difficult to reload the model of a VM in
the process of being cloned. All we have is the vmware managed object
reference ID string and the name of the VM.
This patch adds a number of improvements:
First, the model of a VM being cloned can reload itself after the VM
finishes cloning, even though we don't have an instance_uuid until the
clone completes.
Because the model can reload itself, it's now possible to do something
like:
c = Fog::Compute[:vsphere]
new_vm_name = "test"
c.vm_clone(:instance_uuid => "abc123", :name => new_vm_name)
my_new_vm = c.servers.find { |vm| vm.name == new_vm_name }
my_new_vm.wait_for { uuid }
puts "New VM is ready! (It has a UUID)"
my_new_vm.wait_for { ipaddress }
puts "New VM is on the network!"
Without this patch, a VM model could not reload itself with an id of
'vm-123', reloading the model only works if the ID is a UUID.
In addition, a number of the attributes of the server model have been
adjusted to be nil values when the VM is in the process of cloning.
This makes it easier to use wait_for conditionals in blocks.
With the introduction of the vm_clone API request, a server
may be returned in the list which does not have a complete
configuration yet. This is because the system is still in
the process of being cloned.
This is a problem because Fog would throw an undefined
method error when calling the config method of the vm managed
object instance.
This patch fixes the problem by checking if the config method
returns something and only sets attributes that are known to be
available for a cloning VM.
Without this patch we have no way to completely destroy
a server instance. This patch adds a vm_destroy API request
and implements the destroy method on the server model.
The vSphere API requires the server to be in a poweredOff state.
The model action and the request do not verify this is the case
before issuing the command.
This patch implements the start, stop and reboot methods for the Server
model instances.
These server model methods share common names with the AWS server model.
This patch also implements the API requests required to control the
power state of a VMware Virtual Machine.
The requests default to issuing shutdown and reboot commands to the
guest operating system itself. However, if force is set to true for
power_off and reboot, then the VM is powered off or reset at the virtual
hardware layer.
This patch adds a request list_virtual_machines which is responsible for
making an API connection and returning a raw "response" object from the
API.
Model instances of a Server (compute resource) are returned as a
collection through the "all" method. The Fog framework calls all on the
instance of the collection.