Maor Lipchuk has uploaded a new change for review.

Change subject: restapi: Validate dest when importing VM
......................................................................

restapi: Validate dest when importing VM

When importing a VM it is mandatory to specify the destination
storage domain. The RESTAPI doesn't currently validate this, and thus
the request is accepted and eventually it generates a NPE since
AbstractBackendStorageDomainContentResource#getDestStorageDomainId is
counting on the storage id.

This patch changes the RESTAPI so that it validates that the id or name
of the destination storage domain has been provided. If it isn't provided it
will generate the following error response:

  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <fault>
    <reason>Incomplete parameters</reason>
    <detail>Action [storageDomain.id|name] required for
doImport</detail>
  </fault>

The patch should keep backward compatibility since before it, we got an
NPE, and now it is being replaced with an informative message.

Change-Id: Id9f0e743de7260b0a838b1da2bd94ac48b28d6be
Bug-Url: https://bugzilla.redhat.com/1081173
Signed-off-by: MAor Lipchuk <[email protected]>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResourceTest.java
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/27007/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
index a5d71fa..a7945c7 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
@@ -38,7 +38,7 @@
 
     @Override
     public Response doImport(Action action) {
-        validateParameters(action, "cluster.id|name");
+        validateParameters(action, "cluster.id|name", "storageDomain.id|name");
 
         Guid destStorageDomainId = getDestStorageDomainId(action);
 
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResourceTest.java
index 85b237a..c738d72 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResourceTest.java
@@ -258,7 +258,7 @@
             resource.doImport(new Action());
             fail("expected WebApplicationException on incomplete parameters");
         } catch (WebApplicationException wae) {
-            verifyIncompleteException(wae, "Action", "doImport", 
"cluster.id|name");
+            verifyIncompleteException(wae, "Action", "doImport", 
"cluster.id|name", "storageDomain.id|name");
         }
     }
 


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

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

Reply via email to