Ravi Nori has uploaded a new change for review. Change subject: restapi : Missing opertions for snapshots in RESTAPI(#867339) ......................................................................
restapi : Missing opertions for snapshots in RESTAPI(#867339) 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: If2bbf6ba2c3f71230d3fdd98ca60c0c3d0f902fb Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=867339 Signed-off-by: Ravi Nori <[email protected]> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/SnapshotResource.java 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 3 files changed, 79 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/63/11163/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 f92813e..33df188 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)}/{oid}") + @Path("{action: (restore/preview/commit/undo)}/{oid}") public ActionResource getActionSubresource(@PathParam("action") String action, @PathParam("oid") String oid); @POST @@ -47,6 +47,27 @@ @Path("restore") public Response restore(Action action); + @POST + @Formatted + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_X_YAML}) + @Actionable + @Path("preview") + public Response preview(Action action); + + @POST + @Formatted + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_X_YAML}) + @Actionable + @Path("commit") + public Response commit(Action action); + + @POST + @Formatted + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_X_YAML}) + @Actionable + @Path("undo") + public Response undo(Action action); + @Path("cdroms") public SnapshotCdRomsResource getSnapshotCdRomsResource(); 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 94130fa..c4a753f 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 @@ -69,6 +69,39 @@ } @Override + public Response undo(Action action) { + action.setAsync(false); + RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(parentId, guid); + Response response = doAction(VdcActionType.RestoreAllSnapshots, + restoreParams, + action, + PollingType.JOB); + return response; + } + + @Override + public Response commit(Action action) { + action.setAsync(false); + RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(parentId, guid); + Response response = doAction(VdcActionType.RestoreAllSnapshots, + restoreParams, + action, + PollingType.JOB); + return response; + } + + @Override + public Response preview(Action action) { + action.setAsync(false); + TryBackToAllSnapshotsOfVmParameters tryBackParams = new TryBackToAllSnapshotsOfVmParameters(parentId, guid); + Response response = doAction(VdcActionType.TryBackToAllSnapshotsOfVm, + tryBackParams, + action, + PollingType.JOB); + 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 d08b729..3c59631 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 @@ -87,6 +87,30 @@ resource.restore(new Action()); } + @Test + public void testPreview() { + setUriInfo(setUpBasicUriExpectations()); + setUpTryBackExpectations(); + control.replay(); + resource.preview(new Action()); + } + + @Test + public void testUndo() { + setUriInfo(setUpBasicUriExpectations()); + setUpRestoreExpectations(); + control.replay(); + resource.undo(new Action()); + } + + @Test + public void testCommit() { + setUriInfo(setUpBasicUriExpectations()); + setUpRestoreExpectations(); + control.replay(); + resource.commit(new Action()); + } + protected UriInfo setUpTryBackExpectations() { return setUpActionExpectations( VdcActionType.TryBackToAllSnapshotsOfVm, -- To view, visit http://gerrit.ovirt.org/11163 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If2bbf6ba2c3f71230d3fdd98ca60c0c3d0f902fb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
