Search in sources :

Example 1 with RemoveCinderDiskVolumeParameters

use of org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters 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 2 with RemoveCinderDiskVolumeParameters

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

the class CreateCinderSnapshotCommand method revertCinderVolume.

private void revertCinderVolume(CinderDisk diskVolumeVolume) {
    RemoveCinderDiskVolumeParameters removeDiskVolumeParam = new RemoveCinderDiskVolumeParameters(diskVolumeVolume);
    Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveCinderDiskVolume, removeDiskVolumeParam, null);
    try {
        future.get();
    } catch (InterruptedException | ExecutionException e) {
        log.error("Fail to revert snapshot id '{}' for disk id '{}'. Exception: {}", diskVolumeVolume.getImageId(), diskVolumeVolume.getId(), e);
    }
}
Also used : RemoveCinderDiskVolumeParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with RemoveCinderDiskVolumeParameters

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

the class RemoveCinderVolumeParentCommand method createChildParams.

private RemoveCinderDiskVolumeParameters createChildParams(CinderDisk cinderDiskVolume) {
    RemoveCinderDiskVolumeParameters childParam = new RemoveCinderDiskVolumeParameters(cinderDiskVolume);
    childParam.setParentCommand(getActionType());
    childParam.setParentParameters(getParameters());
    childParam.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    return childParam;
}
Also used : RemoveCinderDiskVolumeParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters)

Example 4 with RemoveCinderDiskVolumeParameters

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

the class RemoveCinderDiskVolumeCommandCallback method childCommandsExecutionEnded.

@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
    RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters> removeCinderDiskVolumeCommand = (RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters>) command;
    CinderDisk removedVolume = removeCinderDiskVolumeCommand.getParameters().getRemovedVolume();
    // In case the volume/snapshot has been deleted from Cinder.
    if (!removeCinderDiskVolumeCommand.getCinderBroker().isVolumeExistsByClassificationType(removedVolume)) {
        setCommandEndStatus(command, false, status, childCmdIds);
    }
    ImageStatus imageStatus = checkImageStatus(removedVolume, removeCinderDiskVolumeCommand);
    if (imageStatus != null && imageStatus != removedVolume.getImageStatus()) {
        switch(imageStatus) {
            case ILLEGAL:
                setCommandEndStatus(command, true, status, childCmdIds);
                break;
        }
    }
}
Also used : RemoveCinderDiskVolumeParameters(org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters) ImageStatus(org.ovirt.engine.core.common.businessentities.storage.ImageStatus) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Aggregations

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