Maor Lipchuk has uploaded a new change for review.

Change subject: core: update managed device map when import cloned VM.
......................................................................

core: update managed device map when import cloned VM.

When importing a cloned VM, we generate a new guid for each disk.
Those new guids should be correlated with the mangedDeviceMap contained
in the VM, so it will keep all the devices configuration as in the old
VM.

Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: I65a99cc0783f670b9288cc9a066cda4d253492a6
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/19954/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 5c93d2a..b463e2e 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,6 +55,7 @@
 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;
@@ -796,7 +797,7 @@
                 setDiskStorageDomainInfo(disk);
 
                 if (getParameters().isImportAsNewEntity()) {
-                    generateNewDiskId(diskList, disk);
+                    generateNewDiskId(diskList, disk, 
getVm().getStaticData().getManagedDeviceMap());
                 } else {
                     newDiskIdForDisk.put(disk.getId(), disk);
                 }
@@ -847,11 +848,15 @@
      * @param disk
      *            - The disk which is about to be cloned
      */
-    private void generateNewDiskId(List<DiskImage> diskList, DiskImage disk) {
+    private void generateNewDiskId(List<DiskImage> diskList, DiskImage disk, 
Map<Guid, VmDevice> managedDeviceMap) {
         Guid newGuidForDisk = Guid.newGuid();
 
         // Copy the disk so it will preserve the old disk id and image id.
         newDiskIdForDisk.put(newGuidForDisk, DiskImage.copyOf(disk));
+
+        Guid oldDiskId = disk.getId();
+        managedDeviceMap.put(newGuidForDisk, 
managedDeviceMap.get(disk.getId()));
+        managedDeviceMap.remove(oldDiskId);
         disk.setId(newGuidForDisk);
         disk.setImageId(Guid.newGuid());
         for (DiskImage diskImage : diskList) {


-- 
To view, visit http://gerrit.ovirt.org/19954
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65a99cc0783f670b9288cc9a066cda4d253492a6
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

Reply via email to