Search in sources :

Example 51 with CinderDisk

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

the class RemoveCinderDiskCommand method executeCommand.

@Override
public void executeCommand() {
    CinderDisk disk = getDisk();
    lockDisk();
    VM vm = getVmForNonShareableDiskImage(disk);
    // so no lock is required.
    if (getParameters().isLockVM() && vm != null) {
        getParameters().setVmId(vm.getId());
        lockVmSnapshotsWithWait(vm);
    }
    getParameters().setRemovedVolume(getDisk());
    getParameters().setStorageDomainId(getDisk().getStorageIds().get(0));
    getParameters().setUpdateSnapshot(true);
    if (getDisk().getImageStatus() == ImageStatus.ILLEGAL) {
        handleRemoveCinderVolumesForIllegal();
        setCommandStatus(CommandStatus.SUCCEEDED);
        setSucceeded(true);
        return;
    }
    // Get the first volume to delete from.
    CinderDisk parentVolume = (CinderDisk) diskImageDao.getSnapshotById(disk.getId());
    initCinderDiskVolumesParametersList(parentVolume);
    if (!removeCinderVolume(0)) {
        imageDao.updateStatusOfImagesByImageGroupId(getDisk().getId(), ImageStatus.ILLEGAL);
        setSucceeded(false);
        return;
    }
    persistCommand(getParameters().getParentCommand(), true);
    getReturnValue().setActionReturnValue(disk.getId());
    setSucceeded(true);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 52 with CinderDisk

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

the class RemoveCinderDiskCommand method handleRemoveCinderVolumesForIllegal.

private void handleRemoveCinderVolumesForIllegal() {
    final List<DiskImage> diskSnapshots = diskImageDao.getAllSnapshotsForImageGroup(cinderDisk.getId());
    ImagesHandler.sortImageList(diskSnapshots);
    TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
        int indCinderVolumeToDelete = diskSnapshots.size() - 1;
        while (indCinderVolumeToDelete >= 0) {
            CinderDisk cinderVolume = (CinderDisk) diskSnapshots.get(indCinderVolumeToDelete);
            Snapshot updated = getSnapshotWithoutCinderVolume(cinderVolume);
            removeDiskFromDb(cinderVolume, updated);
            indCinderVolumeToDelete--;
        }
        return null;
    });
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 53 with CinderDisk

use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk 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)

Example 54 with CinderDisk

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

the class DisksFilterTest method testFilterNonLunDisks.

@Test
public void testFilterNonLunDisks() {
    Disk lunDisk = createDisk(DiskStorageType.LUN, false, false, false, false);
    Disk imageDisk = createDisk(DiskStorageType.IMAGE, false, false, true, false);
    Disk cinderDisk = createDisk(DiskStorageType.CINDER, false, false, true, false);
    List<Disk> disksList = Arrays.asList(lunDisk, imageDisk, cinderDisk);
    List<LunDisk> filteredList = DisksFilter.filterLunDisks(disksList);
    assertEquals(1, filteredList.size());
    assertThat(filteredList, containsInAnyOrder(lunDisk));
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

Example 55 with CinderDisk

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

the class GetDiskAndSnapshotsByDiskIdQueryTest method testQueryWithCinderDisk.

@Test
public void testQueryWithCinderDisk() {
    DiskImage disk = executeQuery(cinderDisk);
    assertTrue("disk should be from type CinderDisk", disk instanceof CinderDisk);
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

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