Search in sources :

Example 1 with RestoreAllSnapshotsParameters

use of org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters in project ovirt-engine by oVirt.

the class RestoreStatelessVmCommand method buildRestoreAllSnapshotsParameters.

private RestoreAllSnapshotsParameters buildRestoreAllSnapshotsParameters(List<DiskImage> imagesList) {
    RestoreAllSnapshotsParameters restoreParameters = new RestoreAllSnapshotsParameters(getVm().getId(), SnapshotActionEnum.RESTORE_STATELESS);
    restoreParameters.setShouldBeLogged(false);
    restoreParameters.setImages(imagesList);
    return restoreParameters;
}
Also used : RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters)

Example 2 with RestoreAllSnapshotsParameters

use of org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters in project ovirt-engine by oVirt.

the class BackendVmResource method commitSnapshot.

@Override
public Response commitSnapshot(Action action) {
    RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(guid, SnapshotActionEnum.COMMIT);
    Response response = doAction(ActionType.RestoreAllSnapshots, restoreParams, action);
    return response;
}
Also used : Response(javax.ws.rs.core.Response) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters)

Example 3 with RestoreAllSnapshotsParameters

use of org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters in project ovirt-engine by oVirt.

the class BackendSnapshotResource method restore.

@Override
public Response restore(Action action) {
    action.setAsync(false);
    TryBackToAllSnapshotsOfVmParameters tryBackParams = new TryBackToAllSnapshotsOfVmParameters(parentId, guid);
    if (action.isSetRestoreMemory()) {
        tryBackParams.setRestoreMemory(action.isRestoreMemory());
    }
    if (action.isSetDisks()) {
        // Each disk parameter is being mapped to a DiskImage.
        List<DiskImage> disks = collection.mapDisks(action.getDisks());
        List<DiskImage> disksFromDB = null;
        if (disks != null) {
            // In case a disk hasn't specified its image_id, the imageId value is set to Guid.Empty().
            disksFromDB = disks.stream().map(disk -> getEntity(org.ovirt.engine.core.common.businessentities.storage.DiskImage.class, QueryType.GetDiskImageByDiskAndImageIds, new GetDiskImageByDiskAndImageIdsParameters(disk.getId(), disk.getImageId()), String.format("GetDiskImageByDiskAndImageIds: disk id=%s, image_id=%s", disk.getId(), disk.getImageId()))).collect(Collectors.toList());
        }
        tryBackParams.setDisks(disksFromDB);
    }
    // TODO: if user supplied, override with user value
    tryBackParams.setCorrelationId(RESTORE_SNAPSHOT_CORRELATION_ID);
    Response response = doAction(ActionType.TryBackToAllSnapshotsOfVm, tryBackParams, action, PollingType.JOB);
    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
        RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(parentId, SnapshotActionEnum.COMMIT);
        restoreParams.setCorrelationId(RESTORE_SNAPSHOT_CORRELATION_ID);
        Response response2 = doAction(ActionType.RestoreAllSnapshots, restoreParams, action);
        if (response2.getStatus() != Response.Status.OK.getStatusCode()) {
            return response2;
        }
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters) TryBackToAllSnapshotsOfVmParameters(org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters) GetDiskImageByDiskAndImageIdsParameters(org.ovirt.engine.core.common.queries.GetDiskImageByDiskAndImageIdsParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 4 with RestoreAllSnapshotsParameters

use of org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters in project ovirt-engine by oVirt.

the class BackendVmResource method undoSnapshot.

@Override
public Response undoSnapshot(Action action) {
    RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(guid, SnapshotActionEnum.UNDO);
    Response response = doAction(ActionType.RestoreAllSnapshots, restoreParams, action);
    return response;
}
Also used : Response(javax.ws.rs.core.Response) RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters)

Example 5 with RestoreAllSnapshotsParameters

use of org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters in project ovirt-engine by oVirt.

the class RestoreAllSnapshotsCommandTest method createCommand.

private RestoreAllSnapshotsCommand<RestoreAllSnapshotsParameters> createCommand() {
    RestoreAllSnapshotsParameters parameters = new RestoreAllSnapshotsParameters(vmId, SnapshotActionEnum.COMMIT);
    List<DiskImage> diskImageList = createDiskImageList();
    parameters.setImages(diskImageList);
    return new RestoreAllSnapshotsCommand<>(parameters, null);
}
Also used : RestoreAllSnapshotsParameters(org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

RestoreAllSnapshotsParameters (org.ovirt.engine.core.common.action.RestoreAllSnapshotsParameters)5 Response (javax.ws.rs.core.Response)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 TryBackToAllSnapshotsOfVmParameters (org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters)1 GetDiskImageByDiskAndImageIdsParameters (org.ovirt.engine.core.common.queries.GetDiskImageByDiskAndImageIdsParameters)1