Search in sources :

Example 1 with CreateCinderSnapshotParameters

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

the class TryBackToAllSnapshotsOfVmCommand method buildCinderChildCommandParameters.

private CreateCinderSnapshotParameters buildCinderChildCommandParameters(CinderDisk cinderDisk, Guid newSnapshotId) {
    CreateCinderSnapshotParameters createParams = new CreateCinderSnapshotParameters(cinderDisk.getImageId());
    createParams.setContainerId(cinderDisk.getId());
    createParams.setStorageDomainId(cinderDisk.getStorageIds().get(0));
    createParams.setDestinationImageId(cinderDisk.getImageId());
    createParams.setVmSnapshotId(newSnapshotId);
    createParams.setParentCommand(getActionType());
    createParams.setParentParameters(getParameters());
    return createParams;
}
Also used : CreateCinderSnapshotParameters(org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters)

Example 2 with CreateCinderSnapshotParameters

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

the class CreateCinderSnapshotCommandCallback method childCommandsExecutionEnded.

@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
    CreateCinderSnapshotCommand<CreateCinderSnapshotParameters> createCinderSnapshotCommand = (CreateCinderSnapshotCommand<CreateCinderSnapshotParameters>) command;
    CreateCinderSnapshotParameters parameters = createCinderSnapshotCommand.getParameters();
    Guid diskId = parameters.getDestinationImageId();
    ImageStatus imageStatus;
    if (parameters.getSnapshotType().equals(Snapshot.SnapshotType.STATELESS)) {
        imageStatus = createCinderSnapshotCommand.getCinderBroker().getDiskStatus(diskId);
    } else {
        imageStatus = createCinderSnapshotCommand.getCinderBroker().getSnapshotStatus(diskId);
    }
    DiskImage disk = diskImageDao.getSnapshotById(diskId);
    if (imageStatus != null && imageStatus != disk.getImageStatus()) {
        switch(imageStatus) {
            case OK:
                setCommandEndStatus(command, false, status, childCmdIds);
                break;
            case ILLEGAL:
                setCommandEndStatus(command, true, status, childCmdIds);
                break;
        }
    }
}
Also used : CreateCinderSnapshotParameters(org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with CreateCinderSnapshotParameters

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

the class CreateSnapshotDiskCommand method buildChildCommandParameters.

private CreateCinderSnapshotParameters buildChildCommandParameters(DiskImage cinderDisk) {
    CreateCinderSnapshotParameters createParams = new CreateCinderSnapshotParameters(((CinderDisk) diskDao.get(cinderDisk.getId())).getImageId());
    createParams.setVmSnapshotId(getParameters().getNewActiveSnapshotId());
    createParams.setStorageDomainId(cinderDisk.getStorageIds().get(0));
    createParams.setDescription(getParameters().getDescription());
    createParams.setSnapshotType(getParameters().getSnapshotType());
    createParams.setParentCommand(getActionType());
    createParams.setParentParameters(getParameters());
    return createParams;
}
Also used : CreateCinderSnapshotParameters(org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters)

Example 4 with CreateCinderSnapshotParameters

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

the class CreateSnapshotDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    for (DiskImage disk : getDisksList()) {
        if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
            CreateCinderSnapshotParameters params = buildChildCommandParameters(disk);
            params.setQuotaId(disk.getQuotaId());
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateCinderSnapshot, params, cloneContext().withoutCompensationContext().withoutLock());
            try {
                ActionReturnValue actionReturnValue = future.get();
                if (!actionReturnValue.getSucceeded()) {
                    log.error("Error creating snapshot for Cinder disk '{}'", disk.getDiskAlias());
                    throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
                }
            } catch (InterruptedException | ExecutionException e) {
                log.error("Error creating snapshot for Cinder disk '{}': {}", disk.getDiskAlias(), e.getMessage());
                throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
            }
            continue;
        }
        ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshot, buildCreateSnapshotParameters(disk), ExecutionHandler.createDefaultContextForTasks(getContext()));
        if (actionReturnValue.getSucceeded()) {
            getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
        } else {
            throw new EngineException(actionReturnValue.getFault().getError(), "Failed to create snapshot!");
        }
    }
    setSucceeded(true);
}
Also used : CreateCinderSnapshotParameters(org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) ExecutionException(java.util.concurrent.ExecutionException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

CreateCinderSnapshotParameters (org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 ExecutionException (java.util.concurrent.ExecutionException)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Guid (org.ovirt.engine.core.compat.Guid)1