1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-13 12:58:17 +03:00

Capture non imported DS error on wild VM import

This commit is contained in:
Tino Vazquez 2017-07-17 12:39:27 +02:00 committed by Ruben S. Montero
parent 77c71baf05
commit c2b0178066

View File

@ -57,16 +57,14 @@ def self.import_wild(host_id, vm_ref, one_vm, template)
dc_ref = vcenter_vm.get_dc.item._ref
ds_ref = template.match(/^VCENTER_DS_REF *= *"(.*)" *$/)[1]
begin
ds_one = dpool.select do |e|
e["TEMPLATE/TYPE"] == "SYSTEM_DS" &&
e["TEMPLATE/VCENTER_DS_REF"] == ds_ref &&
e["TEMPLATE/VCENTER_DC_REF"] == dc_ref &&
e["TEMPLATE/VCENTER_INSTANCE_ID"] == vc_uuid
end.first
rescue
raise "DS with ref #{ds_ref} is not imported in OpenNebula, aborting Wild VM import."
end
ds_one = dpool.select do |e|
e["TEMPLATE/TYPE"] == "SYSTEM_DS" &&
e["TEMPLATE/VCENTER_DS_REF"] == ds_ref &&
e["TEMPLATE/VCENTER_DC_REF"] == dc_ref &&
e["TEMPLATE/VCENTER_INSTANCE_ID"] == vc_uuid
end.first
raise "DS with ref #{ds_ref} is not imported in OpenNebula, aborting Wild VM import." if !ds_one
rc = one_vm.allocate(template)
return rc if OpenNebula.is_error?(rc)