Gilad Chaplik has uploaded a new change for review.

Change subject: restapi: wrong disk_profile when cloning to another SD
......................................................................

restapi: wrong disk_profile when cloning to another SD

When creating VM from template and cloning the disks to a different
storage domain (SD) (not the original template's disks), causes wrong 
disk_profile
error.

Change-Id: I28f59d31d963e226d2da21751b185714fd57763f
Bug-Url: https://bugzilla.redhat.com/1177940
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/36591/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
index 4a864d2..0e5623d 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
@@ -8,6 +8,7 @@
 import java.util.Set;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
+import org.apache.commons.lang.ObjectUtils;
 import org.ovirt.engine.api.common.util.DetailHelper;
 import org.ovirt.engine.api.model.Action;
 import org.ovirt.engine.api.model.Certificate;
@@ -419,6 +420,17 @@
             for (Disk disk : disks.getDisks()) {
                 DiskImage templateDisk = 
templatesDisksMap.get(asGuid(disk.getId()));
                 if( templateDisk != null ) {
+                    // when disk profile isn't specified, and disks are cloned 
to another storage
+                    // domain then the original disk, disk profile is cleared 
since template disk
+                    // disk profile isn't matching destination storage domain.
+                    if (!disk.isSetDiskProfile()
+                            && disk.isSetStorageDomains()
+                            && disk.getStorageDomains().isSetStorageDomains()
+                            && 
disk.getStorageDomains().getStorageDomains().get(0).isSetId()
+                            && 
!ObjectUtils.equals(disk.getStorageDomains().getStorageDomains().get(0).getId(),
+                                    templateDisk.getStorageIds().get(0))) {
+                        templateDisk.setDiskProfileId(null);
+                    }
                     disksMap.put(templateDisk.getId(), map(disk, 
templateDisk));
                 } else {
                     throw new 
WebApplicationException(Response.Status.NOT_FOUND);


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28f59d31d963e226d2da21751b185714fd57763f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to