Tomas Jelinek has uploaded a new change for review.

Change subject: restapi: VM created from template -> "Bad volume specification"
......................................................................

restapi: VM created from template -> "Bad volume specification"

When creating a VM from template using API, the iso_path of the VM
will be set to null, which is not correct for the VDSM.

Change-Id: I193c28ebdf9c8bfc4fea66a5afda15c4fd8861db
Bug-Url: https://bugzilla.redhat.com/857690
Signed-off-by: Tomas Jelinek <tjeli...@redhat.com>
---
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/VmMapperTest.java
2 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/8376/1

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 18ef9ca..3962244 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
@@ -82,7 +82,7 @@
         staticVm.setdefault_boot_sequence(entity.getdefault_boot_sequence());
         staticVm.setvm_type(entity.getvm_type());
         entity.setdefault_display_type(entity.getdefault_display_type());
-        staticVm.setiso_path(entity.getiso_path());
+        staticVm.setiso_path(entity.getiso_path() != null ? 
entity.getiso_path() : "");
         staticVm.setnum_of_sockets(entity.getnum_of_sockets());
         staticVm.setcpu_per_socket(entity.getcpu_per_socket());
         staticVm.setkernel_url(entity.getkernel_url());
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 0dc377b..a17c7a6 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
@@ -15,6 +15,7 @@
 import org.ovirt.engine.core.common.businessentities.VmDynamic;
 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.config.ConfigValues;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.NGuid;
@@ -106,6 +107,23 @@
     }
 
     @Test
+    public void testTemplateWithEmptyIsoPath() {
+        runAndCheckTemplateIsoMapping(null, "");
+    }
+
+    @Test
+    public void testTemplateWithSetIsoPath() {
+        runAndCheckTemplateIsoMapping("someIsoPath", "someIsoPath");
+    }
+
+    private void runAndCheckTemplateIsoMapping(String isoOnTemplate, String 
expected) {
+        VmTemplate template = new VmTemplate();
+        template.setiso_path(isoOnTemplate);
+        VmStatic res = VmMapper.map(template, null);
+        assertEquals(res.getiso_path(), expected);
+    }
+
+    @Test
     public void testGustIp() {
         org.ovirt.engine.core.common.businessentities.VM vm = new 
org.ovirt.engine.core.common.businessentities.VM();
         VmDynamic vmDynamic = new VmDynamic();


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

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

Reply via email to