Search in sources :

Example 1 with CreateSnapshotForVmParameters

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

the class RunVmCommand method createStatelessSnapshot.

private void createStatelessSnapshot() {
    warnIfNotAllDisksPermitSnapshots();
    log.info("Creating stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
    CreateSnapshotForVmParameters createAllSnapshotsFromVmParameters = buildCreateSnapshotParameters();
    ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshotForVm, createAllSnapshotsFromVmParameters, createContextForStatelessSnapshotCreation());
    // setting lock to null in order not to release lock twice
    setLock(null);
    setSucceeded(actionReturnValue.getSucceeded());
    if (!actionReturnValue.getSucceeded()) {
        if (areDisksLocked(actionReturnValue)) {
            throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
        }
        getReturnValue().setFault(actionReturnValue.getFault());
        log.error("Failed to create stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 2 with CreateSnapshotForVmParameters

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

the class BackendSnapshotsResource method doAdd.

protected Response doAdd(Snapshot snapshot, boolean block) {
    validateParameters(snapshot, "description");
    CreateSnapshotForVmParameters snapshotParams = new CreateSnapshotForVmParameters(parentId, snapshot.getDescription());
    if (snapshot.isSetPersistMemorystate()) {
        snapshotParams.setSaveMemory(snapshot.isPersistMemorystate());
    }
    if (snapshot.isSetDiskAttachments()) {
        Map<Guid, Guid> diskToImageIds = mapDisks(snapshot.getDiskAttachments());
        snapshotParams.setDiskIds(diskToImageIds.keySet());
        snapshotParams.setDiskToImageIds(diskToImageIds);
    }
    return performCreate(ActionType.CreateSnapshotForVm, snapshotParams, new SnapshotIdResolver(), block);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 3 with CreateSnapshotForVmParameters

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

the class GlusterStorageSyncCommand method getCreateSnapshotParameters.

protected CreateSnapshotForVmParameters getCreateSnapshotParameters(VM vm) {
    Set<Guid> diskIds = vm.getDiskList().stream().map(BaseDisk::getId).collect(Collectors.toSet());
    CreateSnapshotForVmParameters params = new CreateSnapshotForVmParameters(vm.getId(), vm.getName() + getStorageDomain().getName() + DR_SNAPSHOT_NAME_SUFFIX, false);
    params.setParentCommand(getActionType());
    params.setSnapshotType(SnapshotType.REGULAR);
    params.setParentParameters(getParameters());
    params.setDiskIds(diskIds);
    params.setNeedsLocking(false);
    params.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return params;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 4 with CreateSnapshotForVmParameters

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

the class LiveMigrateDiskCommand method getCreateSnapshotParameters.

protected CreateSnapshotForVmParameters getCreateSnapshotParameters() {
    CreateSnapshotForVmParameters params = new CreateSnapshotForVmParameters(getParameters().getVmId(), getDiskAlias() + " " + StorageConstants.LSM_AUTO_GENERATED_SNAPSHOT_DESCRIPTION, false);
    params.setParentCommand(ActionType.LiveMigrateDisk);
    params.setSnapshotType(Snapshot.SnapshotType.REGULAR);
    params.setParentParameters(getParameters());
    params.setImagesParameters(getParameters().getImagesParameters());
    params.setTaskGroupSuccess(getParameters().getTaskGroupSuccess());
    params.setDiskIds(getImageGroupIds());
    params.setDiskIdsToIgnoreInChecks(getImageGroupIds());
    params.setNeedsLocking(false);
    params.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return params;
}
Also used : CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 5 with CreateSnapshotForVmParameters

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

the class RunVmCommand method buildCreateSnapshotParameters.

private CreateSnapshotForVmParameters buildCreateSnapshotParameters() {
    CreateSnapshotForVmParameters parameters = new CreateSnapshotForVmParameters(getVm().getId(), STATELESS_SNAPSHOT_DESCRIPTION, false);
    parameters.setShouldBeLogged(false);
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    parameters.setEntityInfo(getParameters().getEntityInfo());
    parameters.setSnapshotType(SnapshotType.STATELESS);
    return parameters;
}
Also used : CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Aggregations

CreateSnapshotForVmParameters (org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)6 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1