Search in sources :

Example 71 with CinderDisk

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

the class AddVmTemplateCommand method validateImages.

protected boolean validateImages() {
    // images related checks
    if (!images.isEmpty()) {
        if (!validateVmNotDuringSnapshot()) {
            return false;
        }
        if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) {
            return false;
        }
        List<CinderDisk> cinderDisks = getCinderDisks();
        CinderDisksValidator cinderDisksValidator = new CinderDisksValidator(cinderDisks);
        if (!validate(cinderDisksValidator.validateCinderDiskLimits())) {
            return false;
        }
        if (!validate(isPassDiscardSupportedForImagesDestSds())) {
            return false;
        }
        List<DiskImage> diskImagesToCheck = DisksFilter.filterImageDisks(images, ONLY_NOT_SHAREABLE, ONLY_ACTIVE);
        diskImagesToCheck.addAll(cinderDisks);
        DiskImagesValidator diskImagesValidator = new DiskImagesValidator(diskImagesToCheck);
        if (!validate(diskImagesValidator.diskImagesNotIllegal()) || !validate(diskImagesValidator.diskImagesNotLocked())) {
            return false;
        }
        MultipleStorageDomainsValidator storageDomainsValidator = getStorageDomainsValidator(getStoragePoolId(), sourceImageDomainsImageMap.keySet());
        if (!validate(storageDomainsValidator.allDomainsExistAndActive())) {
            return false;
        }
        Set<Guid> destImageDomains = getStorageGuidSet();
        destImageDomains.removeAll(sourceImageDomainsImageMap.keySet());
        for (Guid destImageDomain : destImageDomains) {
            StorageDomain storage = storageDomainDao.getForStoragePool(destImageDomain, getVm().getStoragePoolId());
            if (storage == null) {
                // domain is not in the same storage pool as the vm
                if (storageDomainStaticDao.get(destImageDomain) == null) {
                    addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST);
                } else {
                    addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL);
                }
                return false;
            }
            if (storage.getStatus() == null || storage.getStatus() != StorageDomainStatus.Active) {
                addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL);
                return false;
            }
            if (storage.getStorageDomainType().isIsoOrImportExportDomain()) {
                addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_ILLEGAL);
                return false;
            }
        }
        return validateSpaceRequirements();
    }
    return true;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) CinderDisksValidator(org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 72 with CinderDisk

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

the class AddVmAndCloneImageCommand method addVmImages.

@Override
protected boolean addVmImages() {
    int numberOfStartedCopyTasks = 0;
    List<DiskImage> cinderDisks = new ArrayList<>();
    try {
        if (!getAdjustedDiskImagesFromConfiguration().isEmpty()) {
            lockEntities();
            for (DiskImage diskImage : getAdjustedDiskImagesFromConfiguration()) {
                // query returned to UI an illegal image)
                if (diskImage.getImageStatus() == ImageStatus.ILLEGAL) {
                    DiskImage snapshotImageInDb = diskImageDao.getSnapshotById(diskImage.getImageId());
                    if (snapshotImageInDb == null) {
                        // If the snapshot diskImage is null, it means the disk was probably
                        // erased after the snapshot was created.
                        // Create a disk to reflect the fact the disk existed during snapshot
                        saveIllegalDisk(diskImage);
                    }
                } else {
                    // Only legal images can be copied
                    if (diskImage.getDiskStorageType() == DiskStorageType.CINDER) {
                        CinderDisk cinder = (CinderDisk) diskImage;
                        cinder.setVmSnapshotId(getVmSnapshotId());
                        cinderDisks.add(cinder);
                        continue;
                    }
                    copyDiskImage(diskImage, diskImage.getStorageIds().get(0), diskInfoDestinationMap.get(diskImage.getId()).getStorageIds().get(0), diskInfoDestinationMap.get(diskImage.getId()).getDiskProfileId(), getActionType());
                    numberOfStartedCopyTasks++;
                }
            }
            addVmCinderDisks(cinderDisks);
        }
    } finally {
        // it is still needed to unlock the entities
        if ((numberOfStartedCopyTasks == 0) && cinderDisks.isEmpty()) {
            unlockEntities();
        }
    }
    return true;
}
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 73 with CinderDisk

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

the class NewDiskModel method flush.

@Override
public void flush() {
    if (!validate()) {
        return;
    }
    super.flush();
    switch(getDiskStorageType().getEntity()) {
        case LUN:
            LunDisk lunDisk = (LunDisk) getDisk();
            LUNs luns = getSanStorageModelBase().getAddedLuns().get(0).getEntity();
            luns.setLunType(getStorageType().getSelectedItem());
            lunDisk.setLun(luns);
            break;
        case CINDER:
            CinderDisk cinderDisk = (CinderDisk) getDisk();
            cinderDisk.setSizeInGigabytes(getSize().getEntity());
            cinderDisk.setVolumeFormat(VolumeFormat.RAW);
            cinderDisk.setCinderVolumeType(getCinderVolumeType().getSelectedItem());
            break;
        default:
            DiskImage diskImage = (DiskImage) getDisk();
            if (getSize() != null && getSize().getEntity() != null) {
                diskImage.setSizeInGigabytes(getSize().getEntity());
            }
            diskImage.setVolumeType(getVolumeType().getSelectedItem());
            diskImage.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(diskImage.getVolumeType(), getStorageDomain().getSelectedItem().getStorageType()));
            break;
    }
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 74 with CinderDisk

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

the class NewTemplateVmModelBehavior method initDisks.

private void initDisks(ArrayList<Disk> disks) {
    Collections.sort(disks, new DiskByDiskAliasComparator());
    ArrayList<DiskModel> list = new ArrayList<>();
    for (Disk disk : disks) {
        DiskModel diskModel = new DiskModel();
        switch(disk.getDiskStorageType()) {
            case IMAGE:
                DiskImage diskImage = (DiskImage) disk;
                diskModel.setSize(new EntityModel<>((int) diskImage.getSizeInGigabytes()));
                ListModel volumes = new ListModel();
                volumes.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList(), diskImage.getVolumeType());
                diskModel.setVolumeType(volumes);
                diskModel.getAlias().setEntity(diskImage.getDiskAlias());
                break;
            case CINDER:
                CinderDisk cinderDisk = (CinderDisk) disk;
                diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
                ListModel volumeTypes = new ListModel();
                volumeTypes.setItems(new ArrayList<>(Arrays.asList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
                diskModel.setVolumeType(volumeTypes);
                diskModel.getAlias().setEntity(cinderDisk.getDiskAlias());
                diskModel.getVolumeFormat().setIsChangeable(false);
                break;
        }
        diskModel.setDisk(disk);
        list.add(diskModel);
        diskModel.getVolumeFormat().setIsAvailable(true);
    }
    getModel().setDisks(list);
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

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