Revision 0492da97

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/importer.rb
53 53

  
54 54
        #template << template_nics
55 55

  
56
        # Get DS_ID for the deployment, the wild VM needs a System DS
57
        dc_ref = vcenter_vm.get_dc.item._ref
58
        ds_ref = template.match(/^VCENTER_DS_REF *= *"(.*)" *$/)[1]
59

  
60
        begin
61
            ds_one = dpool.select do |e|
62
                e["TEMPLATE/TYPE"]                == "SYSTEM_DS" &&
63
                e["TEMPLATE/VCENTER_DS_REF"]      == ds_ref &&
64
                e["TEMPLATE/VCENTER_DC_REF"]      == dc_ref &&
65
                e["TEMPLATE/VCENTER_INSTANCE_ID"] == vc_uuid
66
            end.first
67
        rescue
68
            raise "DS with ref #{ds_ref} is not imported in OpenNebula, aborting Wild VM import."
69
        end
70

  
56 71
        rc = one_vm.allocate(template)
57 72
        return rc if OpenNebula.is_error?(rc)
58 73

  
59
        rc = one_vm.deploy(host_id, false)
74
        rc = one_vm.deploy(host_id, false, ds_one.id)
60 75
        return rc if OpenNebula.is_error?(rc)
61 76

  
62 77
        # Set reference to template disks and nics in VM template
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
602 602
        str << "IMPORT_VM_ID =\"#{self["_ref"]}\"\n"
603 603
        str << "IMPORT_STATE =\"#{@state}\"\n"
604 604

  
605
        # Get DS information
606
        ds_folder = get_dc.datastore_folder
607
        ds_name   = self["config.datastoreUrl"][0].name
608
        ds_folder.fetch!
609
        ds_vcenter_ref = ds_folder.items.select{|_,d| d["name"] == ds_name}.values[0]["_ref"]
610
        str << "VCENTER_DS_REF = \"#{ds_vcenter_ref}\"\n"
611

  
605 612
        vnc_port = nil
606 613
        keymap = nil
607 614

  

Also available in: Unified diff