1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Fix nested folders in get virtual machine

This commit is contained in:
alan 2015-06-05 10:12:51 -07:00
parent 268c6d5502
commit 458644e745

View file

@ -31,9 +31,10 @@ module Fog
def get_vm_by_name(name, dc) def get_vm_by_name(name, dc)
vms = raw_list_all_virtual_machines(dc) vms = raw_list_all_virtual_machines(dc)
if name.include?('/') if name.include?('/')
folder, basename = name.split('/') folder = File.dirname(name)
vms.keep_if { |v| v["name"] == basename && v.parent["name"] == folder }.first basename = File.basename(name)
vms.keep_if { |v| v["name"] == basename && v.parent.pretty_path.include?(folder) }.first
else else
vms.keep_if { |v| v["name"] == name }.first vms.keep_if { |v| v["name"] == name }.first
end end