# File lib/fog/vsphere/requests/compute/find_vm_by_ref.rb, line 12 def find_vm_by_ref(options = {}) raise ArgumentError, "Must pass a vm_ref option" unless options['vm_ref'] # This is the inefficient call all_vm_attributes = list_virtual_machines['virtual_machines'] # Find the VM attributes of the reference if vm_attributes = all_vm_attributes.find { |vm| vm['mo_ref'] == options['vm_ref'] } response = { 'virtual_machine' => vm_attributes } else raise Fog::Compute::Vsphere::NotFound, "VirtualMachine with Managed Object Reference #{options['vm_ref']} could not be found." end response end