Maor Lipchuk has uploaded a new change for review.

Change subject: core: Sync Template disks with new guid..
......................................................................

core: Sync Template disks with new guid..

Currently ImportVmTemplateCommand use two different kinds of containers
when importing a Template disk guids and image guids.

The use of those containers has dependency with each other,
and should be reflected in only one container so it will remain in
sync.

the following fix, put those parameters into one map, and use this
map when copying a new disk into the Data Center.

Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: I5d0ef009e24aac07e2623dbef0fb762ca333888c
---
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
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
3 files changed, 11 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/20002/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 9fcbcbd..411ffa0 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
@@ -104,11 +104,6 @@
     private static VmStatic vmStaticForDefaultValues = new VmStatic();
     private List<DiskImage> imageList;
 
-    /**
-     * Map which contains the disk id (new generated id if the disk is cloned) 
and the disk parameters from the export
-     * domain.
-     */
-    private final Map<Guid, DiskImage> newDiskIdForDisk = new HashMap<>();
     private final List<String> macsAdded = new ArrayList<String>();
     private final SnapshotsManager snapshotsManager = new SnapshotsManager();
 
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 b3a3d6b..776d207 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
@@ -58,9 +58,6 @@
 public class ImportVmTemplateCommand extends 
MoveOrCopyTemplateCommand<ImportVmTemplateParameters>
         implements QuotaStorageDependent {
 
-    private final List<Guid> diskGuidList = new ArrayList<Guid>();
-    private final List<Guid> imageGuidList = new ArrayList<Guid>();
-
     public ImportVmTemplateCommand(ImportVmTemplateParameters parameters) {
         super(parameters);
         setVmTemplate(parameters.getVmTemplate());
@@ -213,8 +210,7 @@
 
     private void initImportClonedTemplateDisks() {
         for (DiskImage image : getParameters().getImages()) {
-            diskGuidList.add(image.getId());
-            imageGuidList.add(image.getImageId());
+            newDiskIdForDisk.put(image.getId(), image);
             if (getParameters().isImportAsNewEntity()) {
                 image.setId(Guid.newGuid());
                 image.setImageId(Guid.newGuid());
@@ -294,13 +290,13 @@
 
             @Override
             public Void runInTransaction() {
-                int i = 0;
                 for (DiskImage disk : disks) {
-                    Guid destinationDomain = 
imageToDestinationDomainMap.get(diskGuidList.get(i));
+                    Guid originalDiskId = 
newDiskIdForDisk.get(disk.getId()).getId();
+                    Guid destinationDomain = 
imageToDestinationDomainMap.get(originalDiskId);
                     MoveOrCopyImageGroupParameters tempVar =
                             new MoveOrCopyImageGroupParameters(containerID,
-                                    diskGuidList.get(i),
-                                    imageGuidList.get(i),
+                                    originalDiskId,
+                                    
newDiskIdForDisk.get(disk.getId()).getImageId(),
                                     disk.getId(),
                                     disk.getImageId(),
                                     destinationDomain,
@@ -316,7 +312,7 @@
                     tempVar.setImportEntity(true);
                     tempVar.setEntityInfo(new 
EntityInfo(VdcObjectType.VmTemplate, containerID));
                     for (DiskImage diskImage : 
getParameters().getVmTemplate().getDiskList()) {
-                        if (diskGuidList.get(i).equals(diskImage.getId())) {
+                        if (originalDiskId.equals(diskImage.getId())) {
                             tempVar.setQuotaId(diskImage.getQuotaId());
                             break;
                         }
@@ -335,7 +331,6 @@
                     }
 
                     
getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList());
-                    i++;
                 }
                 return null;
             }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
index 7f3b220..dff11f9 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
@@ -46,6 +46,11 @@
 @Deprecated
 public class MoveOrCopyTemplateCommand<T extends MoveOrCopyParameters> extends 
StorageDomainCommandBase<T> {
 
+    /**
+     * Map which contains the disk id (new generated id if the disk is cloned) 
and the disk parameters from the export
+     * domain.
+     */
+    protected final Map<Guid, DiskImage> newDiskIdForDisk = new HashMap<>();
     protected Map<Guid, Guid> imageToDestinationDomainMap;
     protected Map<Guid, DiskImage> imageFromSourceDomainMap;
     private List<PermissionSubject> permissionCheckSubject;


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

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