Search in sources :

Example 66 with CinderDisk

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

the class VmModelBehaviorBase method initStorageDomainsForCinderDisks.

private void initStorageDomainsForCinderDisks(List<DiskModel> cinderDisks, Collection<StorageDomain> cinderStorageDomains) {
    for (DiskModel diskModel : cinderDisks) {
        CinderDisk cinderDisk = (CinderDisk) diskModel.getDisk();
        diskModel.getStorageDomain().setItems(Linq.filterStorageDomainById(cinderStorageDomains, cinderDisk.getStorageIds().get(0)));
        diskModel.getStorageDomain().setIsChangeable(false);
        diskModel.getDiskProfile().setIsChangeable(false);
        diskModel.getDiskProfile().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().notSupportedForCinderDisks());
    }
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 67 with CinderDisk

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

the class AbstractDiskModel method flush.

public void flush() {
    switch(getDiskStorageType().getEntity()) {
        case LUN:
            LunDisk lunDisk = getLunDisk();
            DiskInterface diskInterface = getDiskInterface().getSelectedItem();
            if (DiskInterface.VirtIO_SCSI.equals(diskInterface)) {
                lunDisk.setSgio(!getIsScsiPassthrough().getEntity() ? null : getIsSgIoUnfiltered().getEntity() ? ScsiGenericIO.UNFILTERED : ScsiGenericIO.FILTERED);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(getIsUsingScsiReservation().getEntity());
                }
            } else {
                getIsScsiPassthrough().setEntity(false);
                lunDisk.setSgio(null);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(false);
                }
            }
            setDisk(lunDisk);
            break;
        case CINDER:
            CinderDisk cinderDisk = getCinderDisk();
            updateQuota(cinderDisk);
            updateDiskSize(cinderDisk);
            setDisk(cinderDisk);
            break;
        case IMAGE:
            DiskImage diskImage = getDiskImage();
            // For a long time it was possible to delete all disk profiles
            if (getDiskProfile().getSelectedItem() != null) {
                diskImage.setDiskProfileId(getDiskProfile().getSelectedItem().getId());
            }
            updateQuota(diskImage);
            updateDiskSize(diskImage);
            setDisk(diskImage);
            break;
    }
    getDisk().setDiskAlias(getAlias().getEntity());
    getDisk().setDiskDescription(getDescription().getEntity());
    getDisk().setWipeAfterDelete(getIsWipeAfterDelete().getEntity());
    getDisk().setShareable(getIsShareable().getEntity());
    getDisk().setPlugged(getIsPlugged().getEntity());
    getDisk().setPropagateErrors(PropagateErrors.Off);
    if (getVm() != null) {
        getDiskVmElement().setReadOnly(getIsReadOnly().getIsAvailable() ? getIsReadOnly().getEntity() : false);
        getDiskVmElement().setBoot(getIsBootable().getEntity());
        getDiskVmElement().setDiskInterface(getDiskInterface().getSelectedItem());
        getDiskVmElement().setPassDiscard(getPassDiscard().getEntity());
    }
}
Also used : DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 68 with CinderDisk

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

the class EditDiskModel method initialize.

@Override
public void initialize() {
    super.initialize();
    setDiskVmElement(getDisk().getDiskVmElementForVm(getVm().getId()));
    disableNonChangeableEntities();
    getAlias().setEntity(getDisk().getDiskAlias());
    getDescription().setEntity(getDisk().getDiskDescription());
    getIsShareable().setEntity(getDisk().isShareable());
    getIsWipeAfterDelete().setEntity(getDisk().isWipeAfterDelete());
    getIsScsiPassthrough().setEntity(getDisk().isScsiPassthrough());
    getIsSgIoUnfiltered().setEntity(getDisk().getSgio() == ScsiGenericIO.UNFILTERED);
    getIsReadOnly().setEntity(getDiskVmElement().isReadOnly());
    getIsBootable().setEntity(getDiskVmElement().isBoot());
    getPassDiscard().setEntity(getDiskVmElement().isPassDiscard());
    switch(getDisk().getDiskStorageType()) {
        case IMAGE:
            DiskImage diskImage = (DiskImage) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.IMAGE);
            getSize().setEntity((int) diskImage.getSizeInGigabytes());
            getVolumeType().setSelectedItem(diskImage.getVolumeType());
            boolean isExtendImageSizeEnabled = getVm() != null && !diskImage.isDiskSnapshot() && ActionUtils.canExecute(Arrays.asList(getVm()), VM.class, ActionType.ExtendImageSize);
            getSizeExtend().setIsChangeable(isExtendImageSizeEnabled);
            break;
        case LUN:
            LunDisk lunDisk = (LunDisk) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.LUN);
            getStorageType().setIsAvailable(false);
            getSize().setEntity(lunDisk.getLun().getDeviceSize());
            getSizeExtend().setIsAvailable(false);
            getIsUsingScsiReservation().setEntity(getDiskVmElement().isUsingScsiReservation());
            break;
        case CINDER:
            CinderDisk cinderDisk = (CinderDisk) getDisk();
            getDiskStorageType().setEntity(DiskStorageType.CINDER);
            getSize().setEntity((int) cinderDisk.getSizeInGigabytes());
            getSizeExtend().setIsChangeable(true);
            break;
    }
    updateReadOnlyChangeability();
    updatePassDiscardChangeability();
    updateWipeAfterDeleteChangeability();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 69 with CinderDisk

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

the class VmHandler method filterImageDisksForVM.

/**
 * Filters the vm image disks/disk devices.<BR/>
 * note: luns will be filtered, only active image disks will be return.
 */
public void filterImageDisksForVM(VM vm) {
    List<DiskImage> filteredDisks = DisksFilter.filterImageDisks(vm.getDiskMap().values(), ONLY_ACTIVE);
    List<CinderDisk> filteredCinderDisks = DisksFilter.filterCinderDisks(vm.getDiskMap().values());
    filteredDisks.addAll(filteredCinderDisks);
    @SuppressWarnings("unchecked") Collection<? extends Disk> vmDisksToRemove = CollectionUtils.subtract(vm.getDiskMap().values(), filteredDisks);
    vm.clearDisks();
    updateDisksForVm(vm, filteredDisks);
    for (Disk diskToRemove : vmDisksToRemove) {
        vm.getManagedVmDeviceMap().remove(diskToRemove.getId());
    }
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 70 with CinderDisk

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

the class RemoveVmCommand method removeCinderDisks.

/**
 * The following method will perform a removing of all cinder disks from vm. These is only DB operation
 */
private Collection<CinderDisk> removeCinderDisks() {
    Collection<CinderDisk> failedRemoveCinderDisks = null;
    if (getParameters().isRemoveDisks()) {
        List<CinderDisk> cinderDisks = getCinderDisks();
        if (cinderDisks.isEmpty()) {
            return Collections.emptyList();
        }
        RemoveAllVmCinderDisksParameters param = new RemoveAllVmCinderDisksParameters(getVmId(), cinderDisks);
        param.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveAllVmCinderDisks, withRootCommandInfo(param), cloneContextAndDetachFromParent());
        try {
            failedRemoveCinderDisks = future.get().getActionReturnValue();
        } catch (InterruptedException | ExecutionException e) {
            failedRemoveCinderDisks = cinderDisks;
            log.error("Exception", e);
        }
    }
    return failedRemoveCinderDisks;
}
Also used : RemoveAllVmCinderDisksParameters(org.ovirt.engine.core.common.action.RemoveAllVmCinderDisksParameters) 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