Martin Beták has uploaded a new change for review.

Change subject: restapi: Apply template on VmPool creation using REST API
......................................................................

restapi: Apply template on VmPool creation using REST API

The BackendVmPoolsResource.mapToVM method ignored the supplied template.
Now it maps the VmTemplate to VmStatic and supplies it to VM that has
client-supplied changes applied to it.

Change-Id: Ibe3939662562aadaee68ae423beb824c3487b01e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=948775
Signed-off-by: Martin Betak <mbe...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/13639/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java
index ebfe75f..e4b187a 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java
@@ -14,7 +14,10 @@
 import org.ovirt.engine.core.common.action.VmPoolParametersBase;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VmDynamic;
 import org.ovirt.engine.core.common.businessentities.VmPoolType;
+import org.ovirt.engine.core.common.businessentities.VmStatic;
+import org.ovirt.engine.core.common.businessentities.VmStatistics;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.queries.GetVmPoolByIdParameters;
@@ -107,12 +110,11 @@
     }
 
     protected VM mapToVM(VmPool model, VmTemplate template) {
-        // REVISIT: we should reverse the mapping order here,
-        // so that we map from template->VM in the first instance
-        // and then override any values (memory size, boot order etc.)
-        // that are set in the client-provided VmPool instance
-        VM vm = getMapper(VmPool.class, VM.class).map(model, null);
-        vm.getStaticData().setMemSizeMb(template.getMemSizeMb());
+        // apply template
+        VmStatic vmStatic = getMapper(VmTemplate.class, 
VmStatic.class).map(template, null);
+        // override with client-provided data
+        VM vm = getMapper(VmPool.class, VM.class).map(model, new VM(vmStatic, 
new VmDynamic(), new VmStatistics()));
+
         return vm;
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe3939662562aadaee68ae423beb824c3487b01e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Beták <mbe...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to