Shahar Havivi has uploaded a new change for review.

Change subject: restapi: RFE add custom UUID for VM
......................................................................

restapi: RFE add custom UUID for VM

Change-Id: I7a86bf7e61f408a1ee4f1e70f20a8a9261f4deab
Signed-off-by: Shahar Havivi <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
6 files changed, 44 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/29212/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 adbe8fd..bd6154f 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
@@ -2638,6 +2638,7 @@
           <!-- also rel="cdroms/disks/nics/watchdogs" links, see Devices below 
-->
           <xs:element name="version" type="TemplateVersion" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="serial_number" minOccurs="0" maxOccurs="1" />
+          <xs:element name="custom_uuid" type="xs:string" minOccurs="0" 
maxOccurs="1" />
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
@@ -3076,6 +3077,7 @@
           <xs:element ref="serial_number" minOccurs="0" maxOccurs="1" />
           <xs:element name="next_run_configuration_exists" type="xs:boolean" 
minOccurs="0" maxOccurs="1"/>
           <xs:element name="numa_tune_mode" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
+          <xs:element name="custom_uuid" type="xs:string" minOccurs="0" 
maxOccurs="1" />
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
index 39e4eec..6cf1377 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
@@ -102,6 +102,7 @@
           vm.serial_number.value: xs:string
           vm.bios.boot_menu.enabled: xs:boolean
           vm.numa_tune_mode: xs:string
+          vm.custom_uuid: xs:string
         description: update the virtual machine in the system for the given 
virtual machine id with the values specified in the request
     urlparams: {}
     headers:
@@ -189,6 +190,7 @@
           vm.serial_number.value: xs:string
           vm.bios.boot_menu.enabled: xs:boolean
           vm.numa_tune_mode: xs:string
+          vm.custom_uuid: xs:string
         description: add a virtual machine to the system from scratch
       # the following signature is for clone VM from a Snapshot - requires the 
Snapshot ID
       - mandatoryArguments: {vm.name: 'xs:string', vm.template.id|name: 
'xs:string', vm.cluster.id|name: 'xs:string',
@@ -243,6 +245,7 @@
           vm.serial_number.value: xs:string
           vm.bios.boot_menu.enabled: xs:boolean
           vm.numa_tune_mode: xs:string
+          vm.custom_uuid: xs:string
         description: add a virtual machine to the system by cloning from a 
snapshot
       # the following signature is for adding VM from a configuration - 
requires the configuration type and the configuration data
       - mandatoryArguments: {vm.initialization.configuration.type: 
'xs:string', vm.initialization.configuration.data: 'xs:string'}
@@ -299,6 +302,7 @@
                 vm.serial_number.value: xs:string
                 vm.bios.boot_menu.enabled: xs:boolean
                 vm.numa_tune_mode: xs:string
+                vm.custom_uuid: xs:string
         description: add a virtual machine to the system from a configuration 
- requires the configuration type and the configuration data
     urlparams: {}
     headers:
@@ -3630,6 +3634,7 @@
           template.version.version_name: xs:string
           template.serial_number.policy: xs:string
           template.serial_number.value: xs:string
+          template.custom_uuid: xs:string
           template.bios.boot_menu.enabled: xs:boolean
         description: update the specified template in the system
     urlparams: {}
@@ -3692,6 +3697,7 @@
           template.serial_number.policy: xs:string
           template.serial_number.value: xs:string
           template.bios.boot_menu.enabled: xs:boolean
+          template.custom_uuid: xs:string
         description: add a new template to the system
     urlparams: {}
     headers:
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 fefa1a4..56535dc 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
@@ -1,5 +1,8 @@
 package org.ovirt.engine.api.restapi.types;
 
+import static 
org.ovirt.engine.api.restapi.types.IntegerMapper.mapMinusOneToNull;
+import static 
org.ovirt.engine.api.restapi.types.IntegerMapper.mapNullToMinusOne;
+
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.api.common.util.StatusUtils;
 import org.ovirt.engine.api.model.Architecture;
@@ -31,9 +34,6 @@
 import org.ovirt.engine.core.common.osinfo.OsRepository;
 import org.ovirt.engine.core.common.utils.SimpleDependecyInjector;
 import org.ovirt.engine.core.compat.Guid;
-
-import static 
org.ovirt.engine.api.restapi.types.IntegerMapper.mapNullToMinusOne;
-import static 
org.ovirt.engine.api.restapi.types.IntegerMapper.mapMinusOneToNull;
 
 public class TemplateMapper {
 
@@ -193,6 +193,14 @@
             SerialNumberMapper.copySerialNumber(model.getSerialNumber(), 
entity);
         }
 
+        if (model.isSetCustomUuid()) {
+            
entity.setCustomUuid(Guid.createGuidFromString(model.getCustomUuid()));
+        }
+
+        if (model.isSetCustomUuid()) {
+            
entity.setCustomUuid(Guid.createGuidFromString(model.getCustomUuid()));
+        }
+
         return entity;
     }
 
@@ -322,6 +330,12 @@
         if (model.isSetSerialNumber()) {
             SerialNumberMapper.copySerialNumber(model.getSerialNumber(), 
staticVm);
         }
+        if (model.isSetCustomUuid()) {
+            
staticVm.setCustomUuid(Guid.createGuidFromString(model.getCustomUuid()));
+        }
+        if (model.isSetCustomUuid()) {
+            
staticVm.setCustomUuid(Guid.createGuidFromString(model.getCustomUuid()));
+        }
         return staticVm;
     }
 
@@ -431,6 +445,13 @@
         if (entity.getSerialNumberPolicy() != null) {
             model.setSerialNumber(SerialNumberMapper.map(entity, null));
         }
+        if (entity.getCustomUuid() != null) {
+            model.setCustomUuid(entity.getCustomUuid().toString());
+        }
+
+        if (entity.getCustomUuid() != null) {
+            model.setCustomUuid(entity.getCustomUuid().toString());
+        }
 
         return model;
     }
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 46b0ca8..75b9e26 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
@@ -9,7 +9,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.api.common.util.StatusUtils;
 import org.ovirt.engine.api.model.AuthorizedKey;
@@ -130,6 +129,7 @@
         staticVm.setCustomSerialNumber(entity.getCustomSerialNumber());
         
staticVm.setSpiceFileTransferEnabled(entity.isSpiceFileTransferEnabled());
         staticVm.setSpiceCopyPasteEnabled(entity.isSpiceCopyPasteEnabled());
+        staticVm.setCustomUuid(entity.getCustomUuid());
         return staticVm;
     }
 
@@ -330,7 +330,9 @@
                 staticVm.setNumaTuneMode(map(mode, null));
             }
         }
-
+        if (vm.isSetCustomUuid()) {
+            
staticVm.setCustomUuid(Guid.createGuidFromString(vm.getCustomUuid()));
+        }
         return staticVm;
     }
 
@@ -576,6 +578,9 @@
         }
         
model.setNextRunConfigurationExists(entity.isNextRunConfigurationExists());
         model.setNumaTuneMode(map(entity.getNumaTuneMode(), null));
+        if (entity.getCustomUuid() != null) {
+            model.setCustomUuid(entity.getCustomUuid().toString());
+        }
         return model;
     }
 
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
index 1614b70..10e32b5 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
@@ -9,6 +9,7 @@
 import org.ovirt.engine.api.restapi.utils.OsTypeMockUtils;
 import org.ovirt.engine.core.common.businessentities.OriginType;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.compat.Guid;
 
 public class TemplateMapperTest
         extends AbstractInvertibleMappingTest<Template, VmTemplate, 
VmTemplate> {
@@ -39,6 +40,7 @@
         }
         from.setTimezone("Australia/Darwin");
         from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM.value());
+        from.setCustomUuid(Guid.newGuid().toString());
         return from;
     }
 
@@ -88,5 +90,6 @@
         assertEquals(model.getSerialNumber().getValue(), 
transform.getSerialNumber().getValue());
         assertEquals(model.getDisplay().isFileTransferEnabled(), 
transform.getDisplay().isFileTransferEnabled());
         assertEquals(model.getDisplay().isCopyPasteEnabled(), 
transform.getDisplay().isCopyPasteEnabled());
+        assertEquals(model.getCustomUuid(), transform.getCustomUuid());
     }
 }
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
index 53d4949..bfb0907 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
@@ -99,6 +99,7 @@
         from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM.value());
         from.getDisplay().setFileTransferEnabled(true);
         from.getDisplay().setCopyPasteEnabled(true);
+        from.setCustomUuid(Guid.newGuid().toString());
         return from;
     }
 
@@ -150,6 +151,7 @@
         assertEquals(model.getSerialNumber().getValue(), 
transform.getSerialNumber().getValue());
         assertEquals(model.getDisplay().isFileTransferEnabled(), 
transform.getDisplay().isFileTransferEnabled());
         assertEquals(model.getDisplay().isCopyPasteEnabled(), 
transform.getDisplay().isCopyPasteEnabled());
+        assertEquals(model.getCustomUuid(), transform.getCustomUuid());
     }
 
     @Test


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

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

Reply via email to