1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
Commit graph

26 commits

Author SHA1 Message Date
Eric Stonfer
9fdbd35415 add host based vmotion 2012-02-27 10:14:31 -05:00
Eric Stonfer
68c18a9ec3 add vm reconfiguration functions for memory cpu / generic spec 2012-01-31 15:43:48 -05:00
Eric Stonfer
bdacbb1666 fix list_virtual_machines when using :folder 2012-01-27 11:05:39 -05:00
Jeff McCune
0ebad09a45 Merge pull request #704 from estonfer/blank_vms
This patch allows the ability to create 'blank' vms in vsphere
2012-01-23 08:40:00 -08:00
Eric Stonfer
88a32dd5ea This patch allows the ability to create 'blank' vms in vsphere 2012-01-21 16:45:34 -05:00
Jeff McCune
246c91fc67 (maint) Whitespace and format only clean up
Without this patch there are some niggling whitespace and formatting
issues introduced by this pull request and change set.

This patch cleans those up and makes git log --check look nice again.
2012-01-19 11:42:39 -08:00
Jeff McCune
67cede19a5 Fix linked clone mocked test unhandled exception
Without this patch, the test for the vSphere linked clone option to the
vm_clone request throws an exception.  For the full exception please see
GH-697 discussion comments on Github at [1]

This patch fixes the issue by removing the cleanup code which is not
necessary for a Mocked test.  The cleanup code was calling a method on
the response_linked object which is not actually in scope.

[1] https://github.com/fog/fog/pull/697
2012-01-19 11:38:25 -08:00
Eric Stonfer
4bcfed0099 whitespace fix 2012-01-17 14:16:22 -05:00
Eric Stonfer
8542632a67 whitespace fix 2012-01-17 13:52:49 -05:00
Eric Stonfer
8e341ad831 Add the ability to create linked clones in vsphere 2012-01-17 11:52:08 -05:00
Eric Stonfer
4ed540badc fixed a conditional that was assigining = rather than evaluating == in vsphere clone routine. This resulted in cloning from folders always failing 2012-01-10 11:56:04 -05:00
geemus
d721a730cc [vsphere] fix whitespace issue in yaml for mocks 2011-12-12 18:37:22 -06:00
Jeff McCune
a36f3888e3 [vsphere] (#10644) Add servers filter to improve clone performance
The behavior without this patch is that the performance of the vm_clone
operation in unacceptably slow for VMware vCenter deployments with
multiple hundreds of virtual machines.

Performance is unacceptable because the vm_clone operation makes
multiple API calls to list _all_ of the VM's in the inventory.  This
patch eliminates the need to list all VM's by adding path and folder
filters to limit our API calls to subtrees of the VMware inventory.

= API Changes =

 * New datacenters request that caches the Datacenter objects for the
   life of the process.
 * New clone() method on the server model that returns a server model of
   the new VM even if it is not yet done cloning.
 * Ability to limit collections to inventory paths by passing the
 * 'folder' filter to the servers collection.  For example:
   `conn = Fog::Compute[:vsphere];
    conn.servers('path' => '/Datacenters/DC1/vm/Templates')`
   this filter will greatly reduce the number of SOAP API calls by
   limiting the server models in the collection to only those in the
   Templates inventory folder.  Note, this is not recursive yet.

= Tests =

Tests have been updated.  The vm_clone request no longer takes an
instance_uuid because we cannot actually use this to search the
inventory efficiently.  Instead, the vm_clone request now requires a
path attribute to allow Fog to search only a subset of the inventory.
2011-11-12 09:39:14 -08:00
Kelsey Hightower
a65db7f594 (#10570) Update Fog::Compute::Vsphere tests
Update `Fog::Compute::Vsphere` tests to reflect the way the
`Fog::Compute::Vsphere#convert_vm_mob_ref_to_attr_hash` method currently
converts a `RbVmomi::VIM::ManagedObject` object to a hash.

Without this patch, tests related to converting an instance of
`RbVmomi::VIM::ManagedObject` to a hash will raise an exception:
NoMethodError: undefined method `collect!' for Hash; causing the test to
fail.

This patch solves the problem by mocking `RbVmomi::VIM::ManagedObject`
with a new `MockManagedObject` class, which provides a `collect!`
method, and the `_ref` and `parent` attributes.

This patch renames fake_vm to fake_vm_mob_ref in order to provide a
more descriptive name for what's actually being tested.

The `Fog::Compute::Vshpere::Mock` class has been updated to require the
rbvmomi library, which prevents an `NameError` exception from being raised
due to the `Fog::Compute::Vsphere::Shared::RbVmomi` constant not being
initialized.

The `Fog::Compute::Vshpere::Mock` class has been updated with a
`get_folder_path` method, which prevents a `NoMethodError` exception
from being raised due to the `get_folder_path` method being undefined.
2011-11-08 02:03:13 -05:00
Carl Caum
762aa624ac Adding a path attribute to the vm_mob_ref hash
This patch adds a new `path` attribute to the vm_mob_ref hash returned
by the `convert_vm_mob_ref_to_attr_hash` method. In order to support the
new `path` attribute, this patch also adds a new `get_folder_path` method
to the `list_virtual_machines` vsphere module.
2011-11-07 13:42:37 -05:00
Carl Caum
b53416abce (#10055) Search vmFolder inventory vs children
This patch changes how the `list_all_virtual_machine_mobs` method
searches for virtual machines. Previously the search was based on
children of the `dc.vmFolder` object. This makes the false assumption
that all children are virtual machines.

Now the search is based on the entire inventory of the `dc.vmFolder`
object, which gives us more control over what we consider a virtual
machine.

This patch also adds a new `find_all_in_inventory` method; a generic
method that can be used to search an inventory for any VMware object
exposed by RbVmomi. Using `find_all_in_inventory` we are able to
traverse VMware folders and pickout specific VMware object, in this case
`RbVmomi::VIM::VirtualMachine`
2011-11-07 13:42:24 -05:00
Jeff McCune
dd9e132de5 Fix vm clone problem when a Guid instance is passed as the instance_uuid
Without this patch the vm_clone requiest would not find a Managed Object
Reference when a UUID that is not a string is passed as the
instance_uuid option.  This is a problem because an unhelpful "undefined
method `parent' for nil:NilClass" would be thrown to the application.

This patch throws a more helpful Fog::Compute::Vsphere::NotFound
exception if the Virtual Machine template is not found.

The tests have been updated to reflect this expectation.
2011-09-14 10:15:19 -07:00
Jeff McCune
743882f032 Refactor requests to return simple hashes and add unit tests
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/
2011-09-10 15:11:18 -07:00
Jeff McCune
dc9a2e4808 (#9124) Add ability to reload the model of a cloning VM
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.
2011-09-10 13:32:59 -07:00
Jeff McCune
ef2833cb20 (#9241) Add vm_clone API request
Without this patch we have no way to clone a new VM
from a template.  This patch adds the vm_clone request
which takes an instance uuid as the source template
to clone from an a name parameter which is the new VM's
name.

The clone operation is handled asynchronously as a vSphere
task object.  The clone request does not return a handle
for this task, which may make it difficult to monitor
the progress of the clone operation from Fog.  A future
enhancement may be to clone and return the task object
itself to monitor progress.
2011-09-10 13:32:58 -07:00
Jeff McCune
856eb7e033 (#9241) Add find_template_by_instance_uuid request
Without this patch we did not have a convenient way to find
a template by instance UUID.  We could only find virtual
machines by instance UUID, which may or may not be a template.

This patch adds a specific request to obtain the VMware managed
object instance of of a specific template.  This is necessary
plumbing for the clone request.
2011-09-10 13:32:58 -07:00
Jeff McCune
4264b1f99c (#9241) Add destroy API request and model action
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.
2011-09-10 13:32:58 -07:00
Jeff McCune
cb4e9701b5 (#9421) Add start, stop, reboot server model methods
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.
2011-09-10 13:32:58 -07:00
Jeff McCune
d6fed7e4e4 (#9241) Add ability to find VMs by UUID
This patch adds two request methods to the compute service for VMware.
First, finding a VM by it's own UUID (from the vmx file) is supported.
This UUID is not guaranteed to be unique so this patch also implements
finding by instance UUID which is guaranteed to be unique.

The server models will primarily use these requests to obtain VM
managed objects to issue commands against.
2011-09-10 13:32:58 -07:00
Jeff McCune
8bc5c768ec (#9241) Add model for Fog::Compute[:vsphere].servers
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.
2011-09-10 13:32:58 -07:00
Jeff McCune
cf75fb1358 (#9241) Add current_time request
Without this patch, no actual API calls are being made through the Fog
layer to the underlying rbvmobi later and ultimately to the vSphere
target API.

This patch adds a simple current_time request which is similar to a
"ping"  The layers and API are exercised fully using this simple API
call to retrieve the current time on the remote system.

This provides:

    >> Fog::Compute[:vsphere].current_time
    Tue Aug 30 20:46:27 UTC 2011
    >> Fog::Compute[:vsphere].requests
    [:current_time]
2011-09-10 13:32:58 -07:00