Maor Lipchuk has uploaded a new change for review. Change subject: core: update managed device map when import cloned VM Template. ......................................................................
core: update managed device map when import cloned VM Template. When importing a cloned VM Template, we generate a new guid for each disk. Those new guids should be correlated with the mangedDeviceMap contained in the VM Template, so it will keep all the devices configuration as in the old VM Template. Signed-off-by: Maor Lipchuk <[email protected]> Change-Id: I3653663ce64a63d876467f3fcc50dfffad599fab --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java 2 files changed, 14 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/16/20016/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java index 78ebadf..3eaba94 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java @@ -55,7 +55,6 @@ import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; -import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDynamic; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmStatistics; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java index 776d207..000b6f0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java @@ -210,10 +210,10 @@ private void initImportClonedTemplateDisks() { for (DiskImage image : getParameters().getImages()) { - newDiskIdForDisk.put(image.getId(), image); if (getParameters().isImportAsNewEntity()) { - image.setId(Guid.newGuid()); - image.setImageId(Guid.newGuid()); + replaceGuidsForDisks(image); + } else { + newDiskIdForDisk.put(image.getId(), image); } } } @@ -228,6 +228,17 @@ } /** + * Generates a new <code>GUID</code> for disk and its volumes and updates all the related attributes. + * + * @param disk + * - The disk which is about to be cloned + */ + private void replaceGuidsForDisks(DiskImage disk) { + generateNewDiskId(disk); + updateManagedDeviceMap(disk, getVmTemplate().getManagedDeviceMap()); + } + + /** * Change the image format to {@link VolumeFormat#COW} in case the SD is a block device and the image format is * {@link VolumeFormat#RAW} and the type is {@link VolumeType#Sparse}. * -- To view, visit http://gerrit.ovirt.org/20016 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3653663ce64a63d876467f3fcc50dfffad599fab Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
