mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
vCenter import wild VMs now add the correct DS
This commit is contained in:
parent
0aa6e9a916
commit
e3b9f6f706
@ -53,10 +53,25 @@ def self.import_wild(host_id, vm_ref, one_vm, template)
|
||||
|
||||
#template << template_nics
|
||||
|
||||
# Get DS_ID for the deployment, the wild VM needs a System DS
|
||||
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
|
||||
|
||||
rc = one_vm.allocate(template)
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = one_vm.deploy(host_id, false)
|
||||
rc = one_vm.deploy(host_id, false, ds_one.id)
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
# Set reference to template disks and nics in VM template
|
||||
|
@ -602,6 +602,13 @@ class Template
|
||||
str << "IMPORT_VM_ID =\"#{self["_ref"]}\"\n"
|
||||
str << "IMPORT_STATE =\"#{@state}\"\n"
|
||||
|
||||
# Get DS information
|
||||
ds_folder = get_dc.datastore_folder
|
||||
ds_name = self["config.datastoreUrl"][0].name
|
||||
ds_folder.fetch!
|
||||
ds_vcenter_ref = ds_folder.items.select{|_,d| d["name"] == ds_name}.values[0]["_ref"]
|
||||
str << "VCENTER_DS_REF = \"#{ds_vcenter_ref}\"\n"
|
||||
|
||||
vnc_port = nil
|
||||
keymap = nil
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user