Revision 954a7e08

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
1066 1066
    end
1067 1067

  
1068 1068
    def import_vcenter_disks(vc_uuid, dpool, ipool)
1069

  
1070 1069
        disk_info = ""
1071 1070
        error = ""
1072 1071

  
......
1095 1094
                break
1096 1095
            end
1097 1096

  
1098
            image_template = VCenterDriver::Datastore.get_image_import_template(disk[:datastore].name,
1097
            image_import = VCenterDriver::Datastore.get_image_import_template(disk[:datastore].name,
1099 1098
                                                                                disk[:path],
1100 1099
                                                                                disk[:type], ipool)
1101
            if !image_template.empty?
1102
                # Then the image is created
1100
            #Image is already in the datastore
1101
            if image_import[:one]
1102
                one_image = image_import[:one]
1103
                # We must update XML so the OPENNEBULA_MANAGED=NO is set
1104
                rc = one_image.update("OPENNEBULA_MANAGED = \"NO\"", true)
1105
                if OpenNebula.is_error?(rc)
1106
                    error = "Could not update VCENTER_TEMPLATE_DISK elements"
1107
                    break
1108
                end
1109

  
1110
                # This is the disk info
1111
                disk_info << "DISK=[\n"
1112
                disk_info << "IMAGE=\"#{one_image["NAME"]}\"\n"
1113
                disk_info << "]\n"
1114
            elsif !image_import[:template].empty?
1115
                # Then the image is created as it's not in the datastore
1103 1116
                one_i = VCenterDriver::VIHelper.new_one_item(OpenNebula::Image)
1104 1117

  
1105 1118
                allocated_images << one_i
1106 1119

  
1107
                rc = one_i.allocate(image_template, datastore_found['ID'].to_i)
1120
                rc = one_i.allocate(image_import[:template], datastore_found['ID'].to_i)
1108 1121

  
1109 1122
                if ::OpenNebula.is_error?(rc)
1110 1123
                    error = "    Error creating disk from template: #{rc.message}. Cannot import the template\n"
......
1127 1140
        end
1128 1141

  
1129 1142
        return error, disk_info
1130

  
1131 1143
    end
1132 1144

  
1133 1145
    #  Checks if a RbVmomi::VIM::VirtualDevice is a disk or a cdrom

Also available in: Unified diff