Revision 95fc9267 src/tm_mad/vcenter/clone

View differences:

src/tm_mad/vcenter/clone
91 91
        new_size = new_size > original_size ? new_size * 1024 : nil
92 92
    end
93 93

  
94
    unmanaged_disk = false
95

  
94 96
    # Unmanaged disks are those with OPENNEBULA_MANAGED=NO or volatile disks
95 97
    # that are created in StorageDRS clusters
96
    unmanaged_disk = (!!disk['OPENNEBULA_MANAGED'] && disk['OPENNEBULA_MANAGED'].downcase == "no") ||
97
                     (target_ds_ref.start_with?('group-') && !!disk["TYPE"] && disk["TYPE"].downcase == "fs")
98
    if (target_ds_ref.start_with?('group-') && !!disk["TYPE"] && disk["TYPE"].downcase == "fs")
99
        unmanaged_disk = true
100
    else
101
        if (disk['OPENNEBULA_MANAGED'] && disk['OPENNEBULA_MANAGED'].downcase == "no")
102
            # Let's check if the disk is really unmanaged
103

  
104
            if one_vm["TEMPLATE/CLONING_TEMPLATE_ID"]
105
                # In this case we're not cloning the disk, althought the disk
106
                # is unmanaged, the disk is treated as persistent until the
107
                # vm is terminated. That way the disk added to the new vcenter
108
                # template is the one that OpenNebula created when the OpenNebula
109
                # VM template was created
110
               unmanaged_disk = true
111
            else
112
                # What's the moref of the template linked to this VM?
113
                template_ref = one_vm["USER_TEMPLATE/VCENTER_TEMPLATE_REF"]
114

  
115
                # What's the ID of the image and the source
116
                image_id     = disk["IMAGE_ID"]
117
                one_image    = VCenterDriver::VIHelper.one_item(OpenNebula::Image, image_id)
118
                one_source   = one_image["SOURCE"]
119

  
120
                # Let's inspect the disks inside the template
121
                # if we found that the image source of the disk matches one of
122
                # the template disks backing paths, then it's really an unmanaged
123
                vc_template    = VCenterDriver::Template.new_from_ref(template_ref, vi_client)
124
                template_disks = vc_template.get_vcenter_disks
125
                found_disks    = template_disks.select { |d| d[:path_wo_ds] == one_source } rescue []
126
                unmanaged_disk = !found_disks.empty?
127
            end
128
        end
129
    end
98 130

  
99 131
    if !unmanaged_disk
100 132
        source_ds_vc = VCenterDriver::Datastore.new_from_ref(source_ds_ref, vi_client)

Also available in: Unified diff