Omer Frenkel has uploaded a new change for review.

Change subject: restapi: add custom properties to templates
......................................................................

restapi: add custom properties to templates

currently custom properties are vm only feature,
so adding also to templates.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1011735
Change-Id: I95261d17138a8a19d52b16f7f84322c051d7bf17
Signed-off-by: Omer Frenkel <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmBaseMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
3 files changed, 14 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/35118/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index 10b7170..32411fc 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -3151,6 +3151,7 @@
           <xs:element ref="serial_number" minOccurs="0" maxOccurs="1" />
           <xs:element name="start_paused" type="xs:boolean" minOccurs="0" 
maxOccurs="1" />
           <xs:element ref="cpu_profile" minOccurs="0" maxOccurs="1"/>
+          <xs:element name="custom_properties" type="CustomProperties" 
minOccurs="0"/>
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
@@ -3174,7 +3175,7 @@
           <xs:element ref="instance_type" minOccurs="0" maxOccurs="1"/>
           <xs:element name="start_time" type="xs:dateTime" minOccurs="0"/>
           <xs:element name="stop_time" type="xs:dateTime" minOccurs="0"/>
-          <xs:element name="custom_properties" type="CustomProperties" 
minOccurs="0"/>
+
           <xs:element name="payloads" type="Payloads" minOccurs="0"/>
           <xs:element name="statistics" type="Statistics" minOccurs="0" 
maxOccurs="1"/>
           <xs:element name="disks" type="Disks" minOccurs="0" maxOccurs="1"/>
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmBaseMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmBaseMapper.java
index c8f9053..1d56f4a 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmBaseMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmBaseMapper.java
@@ -7,6 +7,7 @@
 import org.ovirt.engine.api.model.Cluster;
 import org.ovirt.engine.api.model.CpuProfile;
 import org.ovirt.engine.api.model.CpuTopology;
+import org.ovirt.engine.api.model.CustomProperties;
 import org.ovirt.engine.api.model.DisplayType;
 import org.ovirt.engine.api.model.Domain;
 import org.ovirt.engine.api.model.HighAvailability;
@@ -14,6 +15,7 @@
 import org.ovirt.engine.api.model.UsbType;
 import org.ovirt.engine.api.model.VmBase;
 import org.ovirt.engine.api.model.VmType;
+import org.ovirt.engine.api.restapi.utils.CustomPropertiesParser;
 import org.ovirt.engine.api.restapi.utils.GuidUtils;
 import org.ovirt.engine.api.restapi.utils.UsbMapperUtils;
 import org.ovirt.engine.core.common.businessentities.OriginType;
@@ -157,6 +159,9 @@
         if (model.isSetCpuProfile() && model.getCpuProfile().isSetId()) {
             
entity.setCpuProfileId(GuidUtils.asGuid(model.getCpuProfile().getId()));
         }
+        if (model.isSetCustomProperties()) {
+            
entity.setCustomProperties(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperty()));
+        }
     }
 
     protected static void mapVmBaseEntityToModel(VmBase model, 
org.ovirt.engine.core.common.businessentities.VmBase entity) {
@@ -233,6 +238,12 @@
             cpuProfile.setId(entity.getCpuProfileId().toString());
             model.setCpuProfile(cpuProfile);
         }
+
+        if (!StringUtils.isEmpty(entity.getCustomProperties())) {
+            CustomProperties hooks = new CustomProperties();
+            
hooks.getCustomProperty().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(),
 false));
+            model.setCustomProperties(hooks);
+        }
     }
 
     @Mapping(from = OriginType.class, to = String.class)
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
index 4a6a4f7..dce74b7 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
@@ -124,6 +124,7 @@
         staticVm.setSpiceCopyPasteEnabled(entity.isSpiceCopyPasteEnabled());
         staticVm.setRunAndPause(entity.isRunAndPause());
         staticVm.setCpuProfileId(entity.getCpuProfileId());
+        staticVm.setCustomProperties(entity.getCustomProperties());
         return staticVm;
     }
 
@@ -170,9 +171,6 @@
         if (vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetGuaranteed()) {
             Long memGuaranteed = vm.getMemoryPolicy().getGuaranteed() / 
BYTES_PER_MB;
             staticVm.setMinAllocatedMem(memGuaranteed.intValue());
-        }
-        if (vm.isSetCustomProperties()) {
-            
staticVm.setCustomProperties(CustomPropertiesParser.parse(vm.getCustomProperties().getCustomProperty()));
         }
         if (vm.isSetQuota() && vm.getQuota().isSetId()) {
             staticVm.setQuotaId(GuidUtils.asGuid(vm.getQuota().getId()));
@@ -402,11 +400,6 @@
         MemoryPolicy policy = new MemoryPolicy();
         policy.setGuaranteed((long)entity.getMinAllocatedMem() * 
(long)BYTES_PER_MB);
         model.setMemoryPolicy(policy);
-        if (!StringUtils.isEmpty(entity.getCustomProperties())) {
-            CustomProperties hooks = new CustomProperties();
-            
hooks.getCustomProperty().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(),
 false));
-            model.setCustomProperties(hooks);
-        }
         if (entity.getQuotaId()!=null) {
             Quota quota = new Quota();
             quota.setId(entity.getQuotaId().toString());


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I95261d17138a8a19d52b16f7f84322c051d7bf17
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Omer Frenkel <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to