Ravi Nori has uploaded a new change for review. Change subject: restapi : Reverting Missing opertions for snapshots in RESTAPI(#867339) ......................................................................
restapi : Reverting Missing opertions for snapshots in RESTAPI(#867339) Reverting change In RESTAPI some opertions for snapshot are missing which are available in webadmin. This patch adds preview, commit and undo operations to the snapshot resource. Change-Id: Ie4c23c4f0032acd90405b2af8fdff8f32d65bee1 Bug-Url: https://bugzilla.redhat.com/867339 Signed-off-by: Ravi Nori <rn...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResourceTest.java 4 files changed, 2 insertions(+), 150 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/21282/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java index 2dcca4a..ddf4eb0 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java @@ -37,7 +37,7 @@ @Formatted public Snapshot get(); - @Path("{action: (restore|preview|commit|undo)}/{oid}") + @Path("{action: (restore)}/{oid}") public ActionResource getActionSubresource(@PathParam("action") String action, @PathParam("oid") String oid); @POST @@ -46,27 +46,6 @@ @Actionable @Path("restore") public Response restore(Action action); - - @POST - @Formatted - @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) - @Actionable - @Path("preview") - public Response preview(Action action); - - @POST - @Formatted - @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) - @Actionable - @Path("commit") - public Response commit(Action action); - - @POST - @Formatted - @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) - @Actionable - @Path("undo") - public Response undo(Action action); @Path("cdroms") public SnapshotCdRomsResource getSnapshotCdRomsResource(); diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index 05bc22f..2f91019 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -813,39 +813,6 @@ headers: Content-Type: {value: application/xml|json, required: true} Correlation-Id: {value: 'any string', required: false} -- name: /api/vms/{vm:id}/snapshots/{snapshot:id}/preview|rel=preview - description: temporarily restores the virtual machine to the state from a given snapshot - request: - body: - parameterType: Action - signatures: - - mandatoryArguments: {} - optionalArguments: {action.restore_memory: 'xs:boolean'} - description: temporarily restores the virtual machine to the state from a given snapshot - urlparams: {} - headers: - Content-Type: {value: application/xml|json, required: true} - Correlation-Id: {value: 'any string', required: false} -- name: /api/vms/{vm:id}/snapshots/{snapshot:id}/commit|rel=commit - description: commit the virtual machine to the current state which has been restored from a snapshot - request: - body: - parameterType: Action - signatures: [] - urlparams: {} - headers: - Content-Type: {value: application/xml|json, required: true} - Correlation-Id: {value: 'any string', required: false} -- name: /api/vms/{vm:id}/snapshots/{snapshot:id}/undo|rel=undo - description: undo a create snapshot operation on a virtual machine - request: - body: - parameterType: Action - signatures: [] - urlparams: {} - headers: - Content-Type: {value: application/xml|json, required: true} - Correlation-Id: {value: 'any string', required: false} - name: /api/vms/{vm:id}/snapshots/{snapshot:id}/cdroms|rel=get description: get the list of cdroms attached to the virtual machine at the time the snapshot was created request: diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java index 30f5861..68a3fed 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResource.java @@ -72,36 +72,6 @@ } @Override - public Response undo(Action action) { - RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(parentId, guid); - Response response = doAction(VdcActionType.RestoreAllSnapshots, - restoreParams, - action); - return response; - } - - @Override - public Response commit(Action action) { - RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(parentId, guid); - Response response = doAction(VdcActionType.RestoreAllSnapshots, - restoreParams, - action); - return response; - } - - @Override - public Response preview(Action action) { - TryBackToAllSnapshotsOfVmParameters tryBackParams = new TryBackToAllSnapshotsOfVmParameters(parentId, guid); - if (action.isSetRestoreMemory()) { - tryBackParams.setRestoreMemory(action.isRestoreMemory()); - } - Response response = doAction(VdcActionType.TryBackToAllSnapshotsOfVm, - tryBackParams, - action); - return response; - } - - @Override public CreationResource getCreationSubresource(String ids) { return inject(new BackendCreationResource(ids)); } diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResourceTest.java index 4bb3446..c1a10e3 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotResourceTest.java @@ -1,30 +1,25 @@ package org.ovirt.engine.api.restapi.resource; -import static org.easymock.EasyMock.expect; import java.util.ArrayList; import java.util.List; import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.junit.Before; import org.junit.Test; import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.ConfigurationType; -import org.ovirt.engine.api.model.CreationStatus; import org.ovirt.engine.api.model.Snapshot; import org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters; import org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters; -import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; -import org.ovirt.engine.core.common.businessentities.AsyncTaskStatus; -import org.ovirt.engine.core.common.businessentities.AsyncTaskStatusEnum; import org.ovirt.engine.core.common.job.JobExecutionStatus; import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; +import static org.easymock.EasyMock.expect; public class BackendSnapshotResourceTest extends AbstractBackendSubResourceTest<Snapshot, org.ovirt.engine.core.common.businessentities.Snapshot, BackendSnapshotResource> { @@ -117,65 +112,6 @@ setUpRestoreExpectations(); control.replay(); resource.restore(new Action()); - } - - @Test - public void testPreview() throws Exception { - setUriInfo(setUpActionExpectations(VdcActionType.TryBackToAllSnapshotsOfVm, - TryBackToAllSnapshotsOfVmParameters.class, - new String[] { "VmId", "DstSnapshotId" }, - new Object[] { VM_ID, SNAPSHOT_ID }, - asList(GUIDS[1]), - asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)))); - Response response = resource.preview(new Action()); - verifyActionResponse(response); - Action action = (Action)response.getEntity(); - assertTrue(action.isSetStatus()); - assertEquals(CreationStatus.COMPLETE.value(), action.getStatus().getState()); - } - - @Test - public void testUndo() throws Exception { - setUriInfo(setUpActionExpectations(VdcActionType.RestoreAllSnapshots, - RestoreAllSnapshotsParameters.class, - new String[] { "VmId", "DstSnapshotId" }, - new Object[] { VM_ID, SNAPSHOT_ID }, - asList(GUIDS[1]), - asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)))); - Response response = resource.undo(new Action()); - verifyActionResponse(response); - Action action = (Action)response.getEntity(); - assertTrue(action.isSetStatus()); - assertEquals(CreationStatus.COMPLETE.value(), action.getStatus().getState()); - } - - @Test - public void testCommit() throws Exception { - setUriInfo(setUpActionExpectations(VdcActionType.RestoreAllSnapshots, - RestoreAllSnapshotsParameters.class, - new String[] { "VmId", "DstSnapshotId" }, - new Object[] { VM_ID, SNAPSHOT_ID }, - asList(GUIDS[1]), - asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)))); - Response response = resource.commit(new Action()); - verifyActionResponse(response); - Action action = (Action)response.getEntity(); - assertTrue(action.isSetStatus()); - assertEquals(CreationStatus.COMPLETE.value(), action.getStatus().getState()); - } - - protected UriInfo setUpActionExpectations(VdcActionType task, - Class<? extends VdcActionParametersBase> clz, - String[] names, - Object[] values, - ArrayList<Guid> asyncTasks, - ArrayList<AsyncTaskStatus> asyncStatuses) { - String uri = "snapshots/" + GUIDS[0] + "/action"; - return setUpActionExpectations(task, clz, names, values, true, true, null, asyncTasks, asyncStatuses, null, null, uri, true); - } - - private void verifyActionResponse(Response r) throws Exception { - verifyActionResponse(r, "snapshots/" + GUIDS[0], true); } protected UriInfo setUpTryBackExpectations() { -- To view, visit http://gerrit.ovirt.org/21282 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie4c23c4f0032acd90405b2af8fdff8f32d65bee1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <rn...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches