Search in sources :

Example 1 with RemoveCinderDiskParameters

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

the class RestoreAllCinderSnapshotsCommand method getRestoreFromSnapshotParams.

private ImagesContainterParametersBase getRestoreFromSnapshotParams(CinderDisk cinderDisk) {
    RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(cinderDisk.getImageId());
    params.setRemovedVolume(cinderDisk);
    params.setParentCommand(getActionType());
    params.setStorageDomainId(cinderDisk.getStorageIds().get(0));
    params.setParentParameters(getParameters());
    return params;
}
Also used : RemoveCinderDiskParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskParameters)

Example 2 with RemoveCinderDiskParameters

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

the class RestoreAllCinderSnapshotsCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    for (CinderDisk cinderDisk : getParameters().getCinderDisksToRestore()) {
        ImagesContainterParametersBase params = getRestoreFromSnapshotParams(cinderDisk);
        restoreCinderDisk(cinderDisk, params);
        // In case we want to undo the previewed snapshot.
        if (getParameters().getSnapshot().getType() == Snapshot.SnapshotType.STATELESS) {
            Guid activeSnapshotId = snapshotDao.get(getParameters().getVmId(), Snapshot.SnapshotType.ACTIVE).getId();
            updateCinderDiskSnapshot(cinderDisk.getId(), activeSnapshotId, cinderDisk.getVmSnapshotId());
        } else if (getParameters().getSnapshot().getType() != Snapshot.SnapshotType.REGULAR) {
            updateCinderDiskSnapshot(cinderDisk.getId(), getParameters().getSnapshot().getId(), null);
        }
    }
    List<CinderDisk> cinderDisksToRemove = getParameters().getCinderDisksToRemove();
    for (CinderDisk cinderDisk : cinderDisksToRemove) {
        RemoveCinderDiskParameters removeDiskParam = new RemoveCinderDiskParameters(cinderDisk.getImageId());
        removeDiskParam.setRemovedVolume(cinderDisk);
        removeDiskParam.setParentCommand(getActionType());
        removeDiskParam.setStorageDomainId(cinderDisk.getStorageIds().get(0));
        removeDiskParam.setParentParameters(getParameters());
        removeDiskParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDisk, removeDiskParam, cloneContextAndDetachFromParent());
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error removing Cinder disk", e);
        }
    }
    List<CinderDisk> cinderVolumesToRemove = getParameters().getCinderVolumesToRemove();
    for (CinderDisk cinderVolume : cinderVolumesToRemove) {
        RemoveCinderDiskVolumeParameters removeDiskVolumeParam = new RemoveCinderDiskVolumeParameters(cinderVolume);
        removeDiskVolumeParam.setParentCommand(getActionType());
        removeDiskVolumeParam.setParentParameters(getParameters());
        removeDiskVolumeParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDiskVolume, removeDiskVolumeParam, cloneContextAndDetachFromParent());
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error removing Cinder disk", e);
        }
    }
    setSucceeded(true);
}
Also used : RemoveCinderDiskParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskParameters) RemoveCinderDiskVolumeParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with RemoveCinderDiskParameters

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

the class RemoveAllVmCinderDisksCommand method buildChildCommandParameters.

private RemoveCinderDiskParameters buildChildCommandParameters(CinderDisk cinderDisk) {
    RemoveCinderDiskParameters removeDiskParams = new RemoveCinderDiskParameters(cinderDisk.getId());
    removeDiskParams.setParentCommand(getActionType());
    removeDiskParams.setParentParameters(getParameters());
    removeDiskParams.setShouldBeLogged(false);
    removeDiskParams.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return removeDiskParams;
}
Also used : RemoveCinderDiskParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskParameters)

Example 4 with RemoveCinderDiskParameters

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

the class CloneSingleCinderDiskCommand method buildRevertParameters.

private RemoveCinderDiskParameters buildRevertParameters(Guid cinderDiskId) {
    RemoveCinderDiskParameters removeDiskParams = new RemoveCinderDiskParameters(cinderDiskId);
    removeDiskParams.setLockVM(false);
    removeDiskParams.setShouldBeLogged(false);
    return removeDiskParams;
}
Also used : RemoveCinderDiskParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskParameters)

Example 5 with RemoveCinderDiskParameters

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

the class RemoveDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    switch(getDisk().getDiskStorageType()) {
        case IMAGE:
            ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveImage, buildRemoveImageParameters(getDiskImage()));
            if (actionReturnValue.getSucceeded()) {
                if (getDisk().getContentType() == DiskContentType.MEMORY_DUMP_VOLUME || getDisk().getContentType() == DiskContentType.MEMORY_METADATA_VOLUME) {
                    removeMemoryDiskFromSnapshotIfNeeded();
                }
                incrementVmsGeneration();
                getReturnValue().getVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
                setSucceeded(true);
            }
            break;
        case LUN:
            removeLunDisk();
            break;
        case CINDER:
            RemoveCinderDiskParameters params = new RemoveCinderDiskParameters(getParameters().getDiskId());
            params.setEndProcedure(EndProcedure.COMMAND_MANAGED);
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDisk, params, cloneContextAndDetachFromParent());
            try {
                setReturnValue(future.get());
                setSucceeded(getReturnValue().getSucceeded());
            } catch (InterruptedException | ExecutionException e) {
                log.error("Error removing Cinder disk '{}': {}", getDiskImage().getDiskAlias(), e.getMessage());
                log.debug("Exception", e);
            }
            break;
    }
}
Also used : RemoveCinderDiskParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

RemoveCinderDiskParameters (org.ovirt.engine.core.common.action.RemoveCinderDiskParameters)5 ExecutionException (java.util.concurrent.ExecutionException)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ImagesContainterParametersBase (org.ovirt.engine.core.common.action.ImagesContainterParametersBase)1 RemoveCinderDiskVolumeParameters (org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 Guid (org.ovirt.engine.core.compat.Guid)1