Arik Hadas has uploaded a new change for review. Change subject: restapi: memory snapshot feature support ......................................................................
restapi: memory snapshot feature support This patch adds support in the REST API for the memory snapshot feature which is about saving the memory state as part of snapshots, so that it will be possible to restore the same state of the VM as it was at the moment the snapshot was taken, when the VM is reverted to the snapshot. An attribute of type boolean which indicates whether the snapshot contains memory or not is added to the snapshot entity. The user can select when creating a snapshot whether the created snapshot should include memory state or not. The user can select when previewing and restoring snapshots whether to restore the snapshot's memory (which means that the memory that is saved in the snapshot, if exists, will be restored when running the VM for the first time after the action is done) or not. Change-Id: I9ccbbaf9a4d242255a4ff999e5f08644d45402eb Bug-Url: https://bugzilla.redhat.com/960931 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd 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/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotsResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/SnapshotMapper.java 6 files changed, 31 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/15687/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index 06af2de..d24fb64 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -179,6 +179,8 @@ <xs:element name="detach" type="xs:boolean" minOccurs="0"/> <!-- import Vm/Template as new entity --> <xs:element name="clone" type="xs:boolean" minOccurs="0" maxOccurs="1"/> + <!-- indicates whether to restore snapshot's memory on preview/restore snapshot --> + <xs:element name="restore_memory" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <!-- ... etc., explicitly enumerate all the parameter types --> </xs:sequence> </xs:group> @@ -2534,6 +2536,7 @@ <xs:element ref="vm" minOccurs="0"/> <xs:element name="date" type="xs:dateTime" minOccurs="0"/> <xs:element name="snapshot_status" type="xs:string" minOccurs="0"/> + <xs:element name="persist_memorystate" type="xs:boolean" minOccurs="0"/> <!-- Also a rel="prev" link --> </xs:sequence> </xs:extension> 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 99a56b9..2c1458d 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 @@ -583,6 +583,8 @@ parameterType: Snapshot signatures: - mandatoryArguments: {snapshot.description: 'xs:string'} + optionalArguments: + snapshot.persist_memorystate: xs:boolean urlparams: {} headers: Content-Type: {value: application/xml|json, required: true} @@ -592,7 +594,9 @@ request: body: parameterType: Action - signatures: [] + signatures: + - mandatoryArguments: {} + optionalArguments: {action.restore_memory: 'xs:boolean'} urlparams: {} headers: Content-Type: {value: application/xml|json, required: true} @@ -601,7 +605,9 @@ request: body: parameterType: Action - signatures: [] + signatures: + - mandatoryArguments: {} + optionalArguments: {action.restore_memory: 'xs:boolean'} urlparams: {} headers: Content-Type: {value: application/xml|json, required: true} 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 ac6f9ff..83fedfb 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 @@ -50,6 +50,9 @@ public Response restore(Action action) { action.setAsync(false); TryBackToAllSnapshotsOfVmParameters tryBackParams = new TryBackToAllSnapshotsOfVmParameters(parentId, guid); + if (action.isSetRestoreMemory()) { + tryBackParams.setRestoreMemory(action.isRestoreMemory()); + } tryBackParams.setCorrelationId(RESTORE_SNAPSHOT_CORRELATION_ID); //TODO: if user supplied, override with user value Response response = doAction(VdcActionType.TryBackToAllSnapshotsOfVm, tryBackParams, @@ -89,6 +92,9 @@ @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); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotsResource.java index 28dbf59..0049e6f 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotsResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendSnapshotsResource.java @@ -43,6 +43,9 @@ validateParameters(snapshot, "description"); CreateAllSnapshotsFromVmParameters snapshotParams = new CreateAllSnapshotsFromVmParameters(parentId, snapshot.getDescription()); + if (snapshot.isSetPersistMemorystate()) { + snapshotParams.setSaveMemory(snapshot.isPersistMemorystate()); + } return performCreate(VdcActionType.CreateAllSnapshotsFromVm, snapshotParams, new SnapshotIdResolver(), diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java index 072b4c2..682210a 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java @@ -53,6 +53,7 @@ if (VersionUtils.greaterOrEqual(version, BackendCapabilitiesResource.VERSION_3_3)) { addFeatureVmApplications(features); addFeatureVnicCustomProperties(features); + addFeatureMemorySnapshot(features); } return features; } @@ -239,4 +240,11 @@ feature.setDescription("Ability to add custom properties to vm nic."); features.getFeature().add(feature); } + + private void addFeatureMemorySnapshot(Features features) { + Feature feature = new Feature(); + feature.setName("Memory Snapshot"); + feature.setDescription("Ability to save memory state as part of snapshot."); + features.getFeature().add(feature); + } } diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/SnapshotMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/SnapshotMapper.java index 72eec48..a890b2b 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/SnapshotMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/SnapshotMapper.java @@ -21,6 +21,9 @@ if (entity.getType() != null) { model.setType(map(entity.getType(), null)); } + if (entity.getMemoryVolume() != null) { + model.setPersistMemorystate(!entity.getMemoryVolume().isEmpty()); + } return model; } -- To view, visit http://gerrit.ovirt.org/15687 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9ccbbaf9a4d242255a4ff999e5f08644d45402eb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
