Daniel Erez has uploaded a new change for review. Change subject: restapi: accept action in remove storage connection ......................................................................
restapi: accept action in remove storage connection Storage connections delete operation now takes an Action as optional parameter. The Action object should contain a Host element from which the connection would be unmounted. Change-Id: I19a0047ee14962eb8a6d0ab2c4e981913d062612 Bug-Url: https://bugzilla.redhat.com/1117278 Signed-off-by: Daniel Erez <[email protected]> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/StorageServerConnectionsResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResource.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResourceTest.java 3 files changed, 27 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/31571/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/StorageServerConnectionsResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/StorageServerConnectionsResource.java index 4e75dd5..c10997f 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/StorageServerConnectionsResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/StorageServerConnectionsResource.java @@ -9,7 +9,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import org.ovirt.engine.api.model.Host; +import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.StorageConnection; import org.ovirt.engine.api.model.StorageConnections; @@ -31,13 +31,13 @@ /** * Deletes the connection from the system, and disconnects the specified host from it * @param id - * @param host + * @param action * @return */ @DELETE @Consumes({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML }) @Path("{id}") - public Response remove(@PathParam("id") String id, Host host); + public Response remove(@PathParam("id") String id, Action action); /** * Deletes the connection from the system diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResource.java index 4580735..c3fae67 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResource.java @@ -4,7 +4,7 @@ import javax.ws.rs.core.Response; -import org.ovirt.engine.api.model.Host; +import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.StorageConnection; import org.ovirt.engine.api.model.StorageConnections; import org.ovirt.engine.api.resource.StorageServerConnectionResource; @@ -21,7 +21,6 @@ private final EntityIdResolver<String> ENTITY_RETRIEVER = new QueryIdResolver<String>(VdcQueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class); - private Host host = null; // host used for removal of connection public BackendStorageServerConnectionsResource() { super(StorageConnection.class, org.ovirt.engine.core.common.businessentities.StorageServerConnections.class); @@ -90,11 +89,19 @@ } @Override - public Response remove(String id, Host host) { - if (host != null) { - this.host = host; + public Response remove(String id, Action action) { + getEntity(id); + StorageServerConnections connection = new StorageServerConnections(); + connection.setid(id); + Guid hostId = Guid.Empty; + + if (action != null && action.isSetHost()) { + hostId = getHostId(action.getHost()); } - return super.remove(id); + + StorageServerConnectionParametersBase parameters = + new StorageServerConnectionParametersBase(connection, hostId); + return performAction(VdcActionType.RemoveStorageServerConnection, parameters); } @Override @@ -102,9 +109,7 @@ StorageServerConnections connection = new StorageServerConnections(); connection.setid(id); Guid hostId = Guid.Empty; - if(this.host != null) { - hostId = getHostId(host); - } + StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, hostId); return performAction(VdcActionType.RemoveStorageServerConnection, parameters); diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResourceTest.java index 6a0b510..77234fa 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageServerConnectionsResourceTest.java @@ -10,6 +10,7 @@ import org.junit.Ignore; import org.junit.Test; +import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.Host; import org.ovirt.engine.api.model.StorageConnection; import org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase; @@ -132,7 +133,9 @@ new Object[] { connection, GUIDS[1] }, true, true)); - verifyRemove(collection.remove(GUIDS[0].toString(), host)); + Action action = new Action(); + action.setHost(host); + verifyRemove(collection.remove(GUIDS[0].toString(), action)); } @Test @@ -142,7 +145,9 @@ host.setId(GUIDS[1].toString()); control.replay(); try { - collection.remove(GUIDS[0].toString(), host); + Action action = new Action(); + action.setHost(host); + collection.remove(GUIDS[0].toString(), action); fail("expected WebApplicationException"); } catch (WebApplicationException wae) { assertNotNull(wae.getResponse()); @@ -165,7 +170,9 @@ false, false)); try { - collection.remove(GUIDS[0].toString(), host); + Action action = new Action(); + action.setHost(host); + collection.remove(GUIDS[0].toString(), action); } catch (WebApplicationException wae) { assertNotNull(wae.getResponse()); assertEquals(400, wae.getResponse().getStatus()); -- To view, visit http://gerrit.ovirt.org/31571 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I19a0047ee14962eb8a6d0ab2c4e981913d062612 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Daniel Erez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
