use of org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters in project ovirt-engine by oVirt.
the class BackendVmResource method previewSnapshot.
@Override
public Response previewSnapshot(Action action) {
validateParameters(action, "snapshot.id");
TryBackToAllSnapshotsOfVmParameters tryBackParams = new TryBackToAllSnapshotsOfVmParameters(guid, asGuid(action.getSnapshot().getId()));
if (action.isSetRestoreMemory()) {
tryBackParams.setRestoreMemory(action.isRestoreMemory());
}
if (action.isSetDisks()) {
// Each disk parameter is being mapped to a DiskImage.
List<DiskImage> disks = getParent().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);
}
if (action.isSetLease()) {
tryBackParams.setRestoreLease(action.getLease().isSetStorageDomain());
if (action.getLease().isSetStorageDomain()) {
tryBackParams.setDstLeaseDomainId(asGuid(action.getLease().getStorageDomain().getId()));
}
}
Response response = doAction(ActionType.TryBackToAllSnapshotsOfVm, tryBackParams, action);
return response;
}
use of org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters 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;
}
use of org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters in project ovirt-engine by oVirt.
the class VmSnapshotListModel method runTryBackToAllSnapshotsOfVm.
private void runTryBackToAllSnapshotsOfVm(final Model model, VM vm, Snapshot snapshot, boolean memory, List<DiskImage> disks, boolean isRestoreLease, Guid leaseDomainId) {
if (model != null) {
model.startProgress();
}
TryBackToAllSnapshotsOfVmParameters params = new TryBackToAllSnapshotsOfVmParameters(vm.getId(), snapshot.getId(), memory, disks);
if (leaseDomainId != null) {
params.setDstLeaseDomainId(leaseDomainId);
}
params.setRestoreLease(isRestoreLease);
Frontend.getInstance().runAction(ActionType.TryBackToAllSnapshotsOfVm, params, result -> {
if (model != null) {
model.stopProgress();
}
if (result.getReturnValue().getSucceeded()) {
cancel();
}
});
}
Aggregations