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=1166632
Change-Id: I95261d17138a8a19d52b16f7f84322c051d7bf17
Signed-off-by: Omer Frenkel <ofren...@redhat.com>
---
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/TemplateMapper.java
2 files changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/35425/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 aa2f55b..a025336 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
@@ -2663,6 +2663,7 @@
           <xs:element ref="console" minOccurs="0" maxOccurs="1"/>
           <xs:element name="timezone" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="domain" minOccurs="0" maxOccurs="1"/>
+          <xs:element name="custom_properties" type="CustomProperties" 
minOccurs="0"/>
           <xs:element ref="usb" minOccurs="0" maxOccurs="1"/>
           <xs:element ref="soundcard_enabled" minOccurs="0" maxOccurs="1"/>
           <xs:element name="tunnel_migration" type="xs:boolean" minOccurs="0" 
maxOccurs="1"/>
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
index 9d28cfb..7ea3084 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
@@ -10,6 +10,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.Display;
 import org.ovirt.engine.api.model.DisplayType;
 import org.ovirt.engine.api.model.Domain;
@@ -21,6 +22,7 @@
 import org.ovirt.engine.api.model.Usb;
 import org.ovirt.engine.api.model.UsbType;
 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.action.UpdateVmTemplateParameters;
@@ -198,6 +200,12 @@
             
entity.setCpuProfileId(GuidUtils.asGuid(model.getCpuProfile().getId()));
         }
 
+        if (!StringUtils.isEmpty(entity.getCustomProperties())) {
+            CustomProperties hooks = new CustomProperties();
+            
hooks.getCustomProperty().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(),
 false));
+            model.setCustomProperties(hooks);
+        }
+
         return entity;
     }
 
@@ -332,6 +340,9 @@
             
staticVm.setCpuProfileId(GuidUtils.asGuid(model.getCpuProfile().getId()));
         }
 
+        if (model.isSetCustomProperties()) {
+            
staticVm.setCustomProperties(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperty()));
+        }
         return staticVm;
     }
 
@@ -446,6 +457,12 @@
             model.setCpuProfile(cpuProfile);
         }
 
+        if (!StringUtils.isEmpty(entity.getCustomProperties())) {
+            CustomProperties hooks = new CustomProperties();
+            
hooks.getCustomProperty().addAll(CustomPropertiesParser.parse(entity.getCustomProperties(),
 false));
+            model.setCustomProperties(hooks);
+        }
+
         return model;
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I95261d17138a8a19d52b16f7f84322c051d7bf17
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Omer Frenkel <ofren...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to