diff --git a/lib/fog/vsphere/requests/compute/get_virtual_machine.rb b/lib/fog/vsphere/requests/compute/get_virtual_machine.rb index 2f4b64bda..ded4a7b61 100644 --- a/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +++ b/lib/fog/vsphere/requests/compute/get_virtual_machine.rb @@ -31,9 +31,10 @@ module Fog def get_vm_by_name(name, dc) vms = raw_list_all_virtual_machines(dc) - if name.include?('/') - folder, basename = name.split('/') - vms.keep_if { |v| v["name"] == basename && v.parent["name"] == folder }.first + if name.include?('/') + folder = File.dirname(name) + basename = File.basename(name) + vms.keep_if { |v| v["name"] == basename && v.parent.pretty_path.include?(folder) }.first else vms.keep_if { |v| v["name"] == name }.first end