Moti Asayag has uploaded a new change for review.

Change subject: restapi: Assure network existence when adding a vnic profile
......................................................................

restapi: Assure network existence when adding a vnic profile

In order to create a vnic profile, the user must provide
the network id to which he wishes to add the profile.
If a network cannot be obtained by the id, the parameters
should consider invalid and a proper message should be
returned.

The backend has logic for this scenario, however when performing
this action with a user that its permissions should be verified,
there is a generic "User is not authorized to perform this action"
even though the message refers to a non-existing network entity.

Change-Id: Ib517cc0fd04c4f0e12fd6bdbdca8c6277600e325
Bug-Url: https://bugzilla.redhat.com/1031369
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVnicProfilesResource.java
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/24304/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVnicProfilesResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVnicProfilesResource.java
index 079755d..5fcf215 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVnicProfilesResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVnicProfilesResource.java
@@ -9,6 +9,8 @@
 import org.ovirt.engine.api.model.VnicProfiles;
 import org.ovirt.engine.api.resource.VnicProfileResource;
 import org.ovirt.engine.api.resource.VnicProfilesResource;
+import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 
@@ -31,6 +33,10 @@
     @Override
     protected void validateParameters(VnicProfile vnicProfile) {
         validateParameters(vnicProfile, "name", "network.id");
+        String networkId = vnicProfile.getNetwork().getId();
+        // verify the network.id is well provided
+        getEntity(Network.class, VdcQueryType.GetNetworkById, new 
IdQueryParameters(asGuid(networkId)), "Network: id="
+                + networkId);
     }
 
     @SingleEntityResource


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

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

Reply via email to