Sahina Bose has uploaded a new change for review. Change subject: restapi: Return error in replace-brick ......................................................................
restapi: Return error in replace-brick Replace brick rest api is no longer supported in the underlying glusterfs. Hence changing the rest api to throw an error advising user to use migrate and add new brick instead Change-Id: I72cf2f62c049a0d515ec1f3fde14155b63b9738f Bug-Url: https://bugzilla.redhat.com/923196 Signed-off-by: Sahina Bose <sab...@redhat.com> --- M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/logging/Messages.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java M backend/manager/modules/restapi/jaxrs/src/main/resources/org/ovirt/engine/api/restapi/logging/Messages.properties M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResourceTest.java 4 files changed, 13 insertions(+), 38 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/26189/1 diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/logging/Messages.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/logging/Messages.java index bb5ef4d..cba986a 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/logging/Messages.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/logging/Messages.java @@ -25,5 +25,7 @@ DUPLICATE_ACCESS_CONTROL_GLUSTER_VOLUME_DETAIL, - CANNOT_ACTIVATE_UNLESS_MIGRATION_COMPLETED + CANNOT_ACTIVATE_UNLESS_MIGRATION_COMPLETED, + + GLUSTER_VOLUME_REPLACE_BRICK_NOT_SUPPORTED } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java index 2b3b19a..0624e5d 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResource.java @@ -9,14 +9,11 @@ import org.ovirt.engine.api.model.GlusterBrick; import org.ovirt.engine.api.resource.StatisticsResource; import org.ovirt.engine.api.resource.gluster.GlusterBrickResource; +import org.ovirt.engine.api.restapi.logging.Messages; import org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource; import org.ovirt.engine.api.restapi.resource.BackendStatisticsResource; import org.ovirt.engine.api.restapi.resource.BrickStatisticalQuery; -import org.ovirt.engine.api.restapi.types.Mapper; -import org.ovirt.engine.core.common.action.VdcActionType; -import org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; -import org.ovirt.engine.core.common.businessentities.gluster.GlusterTaskOperation; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.queries.IdQueryParameters; @@ -60,15 +57,10 @@ @Override public Response replace(Action action) { - validateParameters(action, "Brick.serverId", "Brick.brickDir"); - Mapper<GlusterBrick, GlusterBrickEntity> mapper = getMapper(GlusterBrick.class, GlusterBrickEntity.class); - return doAction(VdcActionType.ReplaceGlusterVolumeBrick, - new GlusterVolumeReplaceBrickActionParameters(asGuid(getVolumeId()), - GlusterTaskOperation.START, - mapper.map(get(), null), - mapper.map(action.getBrick(), null), - action.isSetForce() ? action.isForce() : false), - action); + throw new WebFaultException(null, + localize(Messages.GLUSTER_VOLUME_REPLACE_BRICK_NOT_SUPPORTED), + Response.Status.SERVICE_UNAVAILABLE); + } public BackendGlusterBricksResource getParent() { diff --git a/backend/manager/modules/restapi/jaxrs/src/main/resources/org/ovirt/engine/api/restapi/logging/Messages.properties b/backend/manager/modules/restapi/jaxrs/src/main/resources/org/ovirt/engine/api/restapi/logging/Messages.properties index 82627de..675d333 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/resources/org/ovirt/engine/api/restapi/logging/Messages.properties +++ b/backend/manager/modules/restapi/jaxrs/src/main/resources/org/ovirt/engine/api/restapi/logging/Messages.properties @@ -11,3 +11,4 @@ DUPLICATE_ACCESS_CONTROL_GLUSTER_VOLUME_REASON=Invalid access control specifications DUPLICATE_ACCESS_CONTROL_GLUSTER_VOLUME_DETAIL=Both access_control_list and auth.allow option should have the same value or only one should be present. CANNOT_ACTIVATE_UNLESS_MIGRATION_COMPLETED=Brick(s) cannot be activated unless data migration is completed +GLUSTER_VOLUME_REPLACE_BRICK_NOT_SUPPORTED=Replace brick is not supported. First migrate brick and add new brick instead. diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResourceTest.java index 219343e..758347b 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterBrickResourceTest.java @@ -17,6 +17,7 @@ import org.junit.Test; import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.Cluster; +import org.ovirt.engine.api.model.Fault; import org.ovirt.engine.api.model.GlusterBrick; import org.ovirt.engine.api.model.GlusterVolume; import org.ovirt.engine.api.model.Statistics; @@ -25,7 +26,6 @@ import org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest; import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; -import org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; @@ -74,34 +74,14 @@ } @Test - public void testReplaceInvalidParams() throws Exception { - setupParentExpectations(); - setUriInfo(setUpBasicUriExpectations()); + public void testReplace() throws Exception { control.replay(); - try { resource.replace(new Action()); + fail("Expected excpetion"); } catch (WebApplicationException wae) { - verifyIncompleteException(wae, "Action", "replace", "Brick.serverId, Brick.brickDir"); + assertTrue(wae.getResponse().getEntity() instanceof Fault); } - } - - @Test - public void testReplace() throws Exception { - setupParentExpectations(); - setUpGetEntityExpectations(1); - setUriInfo(setUpActionExpectations(VdcActionType.ReplaceGlusterVolumeBrick, - GlusterVolumeReplaceBrickActionParameters.class, - new String[] { "VolumeId", "NewBrick.ServerId", "NewBrick.BrickDirectory" }, - new Object[] { volumeId, serverId, GlusterTestHelper.brickDir })); - resource.setParent(bricksResourceMock); - - Action action = new Action(); - action.setBrick(new GlusterBrick()); - action.getBrick().setServerId(serverId.toString()); - action.getBrick().setBrickDir(GlusterTestHelper.brickDir); - - verifyActionResponse(resource.replace(action)); } @Test -- To view, visit http://gerrit.ovirt.org/26189 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I72cf2f62c049a0d515ec1f3fde14155b63b9738f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Sahina Bose <sab...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches