Search in sources :

Example 21 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveAllVmCinderDisksCommand method getCinderDisksToBeRemoved.

private List<CinderDisk> getCinderDisksToBeRemoved() {
    List<CinderDisk> imageDisks = getParameters().cinderDisks;
    List<CinderDisk> cinderDisks = new ArrayList<>();
    if (imageDisks == null) {
        cinderDisks = DisksFilter.filterCinderDisks(diskDao.getAllForVm(getVmId()));
    } else {
        for (DiskImage diskImage : imageDisks) {
            cinderDisks.add((CinderDisk) diskImage);
        }
    }
    return cinderDisks;
}
Also used : ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 22 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveAllVmCinderDisksCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    Collection<CinderDisk> failedRemoving = new LinkedList<>();
    for (final CinderDisk cinderDisk : getCinderDisksToBeRemoved()) {
        if (Boolean.TRUE.equals(cinderDisk.getActive())) {
            ActionReturnValue actionReturnValuernValue = removeCinderDisk(cinderDisk);
            if (actionReturnValuernValue == null || !actionReturnValuernValue.getSucceeded()) {
                failedRemoving.add(cinderDisk);
                logRemoveCinderDiskError(cinderDisk, actionReturnValuernValue);
            }
        }
    }
    setActionReturnValue(failedRemoving);
    persistCommand(getParameters().getParentCommand(), true);
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LinkedList(java.util.LinkedList)

Example 23 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveCinderDiskVolumeCommand method endWithFailure.

@Override
protected void endWithFailure() {
    super.endWithFailure();
    CinderDisk cinderVolume = getParameters().getRemovedVolume();
    log.error("Could not remove Cinder volume id '{}' of disk id '{}'.", cinderVolume.getImageId(), cinderVolume.getId());
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 24 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class RemoveCinderDiskVolumeCommand method executeCommand.

@Override
public void executeCommand() {
    CinderDisk volumeToDelete = getParameters().getRemovedVolume();
    if (!deleteVolumeFromCinder(volumeToDelete)) {
        setCommandStatus(CommandStatus.FAILED);
    }
    persistCommand(getParameters().getParentCommand(), true);
    setSucceeded(true);
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 25 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.

the class UpdateVmDiskCommand method extendCinderDiskSize.

private void extendCinderDiskSize() {
    lockImageInDb();
    CinderDisk newCinderDisk = (CinderDisk) getNewDisk();
    Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.ExtendCinderDisk, buildExtendCinderDiskParameters(newCinderDisk), cloneContextAndDetachFromParent());
    addCustomValue("NewSize", String.valueOf(getNewDiskSizeInGB()));
    try {
        setReturnValue(future.get());
        setSucceeded(getReturnValue().getSucceeded());
    } catch (InterruptedException | ExecutionException e) {
        log.error("Error extending Cinder disk '{}': {}", getNewDisk().getDiskAlias(), e.getMessage());
        log.debug("Exception", e);
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)74 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)28 Guid (org.ovirt.engine.core.compat.Guid)19 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)15 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)14 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 ArrayList (java.util.ArrayList)12 ImagesContainterParametersBase (org.ovirt.engine.core.common.action.ImagesContainterParametersBase)9 ExecutionException (java.util.concurrent.ExecutionException)7 VM (org.ovirt.engine.core.common.businessentities.VM)6 HashMap (java.util.HashMap)5 List (java.util.List)5 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)5 Map (java.util.Map)4 Test (org.junit.Test)4 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)4 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3