diff --git a/lib/rbvmomi/vim/Folder.rb b/lib/rbvmomi/vim/Folder.rb index 9d052181..6ea63619 100644 --- a/lib/rbvmomi/vim/Folder.rb +++ b/lib/rbvmomi/vim/Folder.rb @@ -53,6 +53,21 @@ def findByUuid uuid, type=RbVmomi::VIM::VirtualMachine, dc=nil x if x.is_a? type end + # Retrieve a virtual machine or host by Instance UUID. + # @param uuid [String] The UUID to find. + # @param type [Class] Return nil unless the found entity is_a? type. + # @param dc [RbVmomi::VIM::Datacenter] Restricts the query to entities in the given Datacenter. + # @return [VIM::ManagedEntity] + def findByInstanceUuid uuid, type=RbVmomi::VIM::VirtualMachine, dc=nil + propSpecs = { + :entity => self, :uuid => uuid, :instanceUuid => true, + :vmSearch => type == RbVmomi::VIM::VirtualMachine + } + propSpecs[:datacenter] = dc if dc + x = _connection.searchIndex.FindByUuid(propSpecs) + x if x.is_a? type + end + # Alias to traverse path, type, true # @see #traverse def traverse! path, type=Object