1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

F #5412: Better error messages in get_dc function

(cherry picked from commit 46b40991b5)
This commit is contained in:
Jaime Melis 2017-09-27 16:30:40 +02:00
parent a5f517ca00
commit 68139ea586

View File

@ -74,16 +74,23 @@ class Template
def get_dc
item = @item
while !item.instance_of? RbVmomi::VIM::Datacenter
if item.parent
item = item.parent
elsif item.resourcePool.instance_of? RbVmomi::VIM::VirtualApp
item = item.resourcePool.parent
trace = []
while item && !item.instance_of?(RbVmomi::VIM::Datacenter)
rp = item.resourcePool rescue nil
if rp && rp.instance_of?(RbVmomi::VIM::VirtualApp)
trace << "rp:" + item.to_s
item = rp.parent rescue nil
else
raise "Could not find the parent Datacenter"
trace << item.to_s
item = item.parent rescue nil
end
end
if item.nil?
trace = "[" + trace.join(", ") + "]"
raise "Could not find the parent Datacenter. Trace: #{trace}"
end
Datacenter.new(item)
end