From 458644e745746df99a771ac82aa4e57f15233f89 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 5 Jun 2015 10:12:51 -0700 Subject: [PATCH] Fix nested folders in get virtual machine --- lib/fog/vsphere/requests/compute/get_virtual_machine.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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