fog/fog — pull request #592 by kelseyhightower (2011-11-07 18:52:47+00:00)
Title: vSphere usability improvements 

commit b53416abce6eb9de2d358e9516540d50a58f8e87
Author: Carl Caum
Date: Fri Oct 28 09:03:02 2011 -0400

(#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`

commit 762aa624ac07f76d774bc852e4737637273cea30
Author: Carl Caum
Date: Fri Oct 28 10:10:37 2011 -0400

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.

commit bc74e06d128ba2cdef60534eecb27174af388219
Author: Kelsey Hightower
Date: Mon Nov 7 07:08:54 2011 -0500

(#10570) Use nil in-place of missing attributes

Without this patch, `Fog::Compute::Vsphere#convert_vm_mob_ref_to_attr_hash`
method produces unhandled exceptions during VMware cloning and listing
operations. The root cause of these exceptions are based on the fact
that some VMware virtual machine attributes: hypervisor name, and
macaddress, are not available until the cloning process has finished.

These exceptions can be triggered when external events take place within
the VMware infrastructure such as end-users cloning machines via some
other VMware management tool.

This patch solves the problem by catching any exceptions that occur
during attribute lookups for both the hypervisor name and the virtual
machine macaddress, and setting them to nil.

This patch also removes the host attribute from the hash generated by
the `Fog::Compute::Vsphere#convert_vm_mob_ref_to_attr_hash` method. The
hypervisor attribute is added instead, which is an alias to host.

This patch changes the behaviour of the
`Fog::Compute::Vsphere#convert_vm_mob_ref_to_attr_hash` method by
catching exceptions for missing attributes, and setting them to nil.