Search in sources :

Example 1 with DiskValidator

use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.

the class AddDiskCommandTest method spyDiskValidator.

private DiskValidator spyDiskValidator(Disk disk) {
    DiskValidator diskValidator = spy(new DiskValidator(disk));
    doReturn(diskValidator).when(command).getDiskValidator(disk);
    return diskValidator;
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator)

Example 2 with DiskValidator

use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.

the class TransferDiskImageCommand method validateImageTransfer.

@Override
protected boolean validateImageTransfer() {
    DiskImage diskImage = getDiskImage();
    DiskValidator diskValidator = getDiskValidator(diskImage);
    DiskImagesValidator diskImagesValidator = getDiskImagesValidator(diskImage);
    StorageDomainValidator storageDomainValidator = getStorageDomainValidator(storageDomainDao.getForStoragePool(diskImage.getStorageIds().get(0), diskImage.getStoragePoolId()));
    return validate(diskValidator.isDiskExists()) && validateActiveDiskPluggedToAnyNonDownVm(diskImage, diskValidator) && validate(diskImagesValidator.diskImagesNotIllegal()) && validate(diskImagesValidator.diskImagesNotLocked()) && validate(storageDomainValidator.isDomainExistAndActive());
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with DiskValidator

use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.

the class AmendImageGroupVolumesCommand method validate.

@Override
protected boolean validate() {
    DiskValidator diskValidator = createDiskValidator();
    if (!validate(diskValidator.isDiskExists())) {
        return false;
    }
    if (!validate(diskValidator.isDiskPluggedToAnyNonDownVm(false))) {
        return false;
    }
    setStoragePoolId(getDiskImage().getStoragePoolId());
    if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) {
        return false;
    }
    if (!FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_AMEND_NOT_SUPPORTED_BY_DC_VERSION, String.format("$dataCenterVersion %s", getStoragePool().getCompatibilityVersion().toString()));
    }
    if (getDiskImage().getVmEntityType().isTemplateType()) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_CANT_AMEND_TEMPLATE_DISK);
    }
    setStorageDomainId(getDiskImage().getStorageIds().get(0));
    StorageDomainValidator storageDomainValidator = new StorageDomainValidator(getStorageDomain());
    if (!validate(storageDomainValidator.isDomainExistAndActive())) {
        return false;
    }
    DiskImagesValidator diskImagesValidator = new DiskImagesValidator(Collections.singletonList(getDiskImage()));
    return validate(diskImagesValidator.diskImagesNotIllegal()) && validate(diskImagesValidator.diskImagesNotLocked());
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator)

Example 4 with DiskValidator

use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.

the class CopyImageGroupCommand method validate.

@Override
protected boolean validate() {
    // Not relevant for import VM/VMTemplate
    if (getParameters().isImportEntity()) {
        return true;
    }
    Guid imageGroupId = Guid.isNullOrEmpty(getParameters().getImageGroupID()) ? getImageGroupId() : getParameters().getImageGroupID();
    Disk disk = diskDao.get(imageGroupId);
    DiskValidator diskValidator = createDiskValidator(disk);
    if (diskValidator.isDiskExists().isValid()) {
        return validate(diskValidator.validateUnsupportedDiskStorageType(DiskStorageType.LUN, DiskStorageType.CINDER));
    }
    return true;
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 5 with DiskValidator

use of org.ovirt.engine.core.bll.validator.storage.DiskValidator in project ovirt-engine by oVirt.

the class AddDiskCommand method validate.

@Override
protected boolean validate() {
    if (!isFloatingDisk() && (!validate(new VmValidator(getVm()).isVmExists()) || !validateDiskVmData())) {
        return false;
    }
    Disk diskInfo = getParameters().getDiskInfo();
    if (diskInfo.getDiskStorageType() == DiskStorageType.IMAGE || diskInfo.getDiskStorageType() == DiskStorageType.CINDER) {
        getDiskImageInfo().setDiskSnapshot(false);
    }
    VM vm = getVm();
    DiskValidator diskValidator = getDiskValidator(getParameters().getDiskInfo());
    DiskVmElementValidator diskVmElementValidator = getDiskVmElementValidator(getParameters().getDiskInfo(), getDiskVmElement());
    if (vm != null) {
        if (!validateDiskVmData() || !canRunActionOnNonManagedVm()) {
            return false;
        }
        updateDisksFromDb();
        if (getDiskVmElement().isBoot() && !validate(diskValidator.isVmNotContainsBootDisk(vm))) {
            return false;
        }
        if (!validatePassDiscardSupported(diskVmElementValidator)) {
            return false;
        }
        // if user sent drive check that its not in use
        if (!isDiskPassPciAndIdeLimit()) {
            return false;
        }
        if (!validate(diskVmElementValidator.isReadOnlyPropertyCompatibleWithInterface())) {
            return false;
        }
    } else if (Boolean.TRUE.equals(getParameters().getPlugDiskToVm())) {
        return failValidation(EngineMessage.CANNOT_ADD_FLOATING_DISK_WITH_PLUG_VM_SET);
    }
    if (!validateQuota()) {
        return false;
    }
    if (DiskStorageType.IMAGE == getParameters().getDiskInfo().getDiskStorageType()) {
        if (!checkIfImageDiskCanBeAdded(vm, diskVmElementValidator)) {
            return false;
        }
        return setAndValidateDiskProfiles();
    }
    if (DiskStorageType.LUN == getParameters().getDiskInfo().getDiskStorageType()) {
        return checkIfLunDiskCanBeAdded(diskValidator);
    }
    if (DiskStorageType.CINDER == getParameters().getDiskInfo().getDiskStorageType()) {
        CinderDisk cinderDisk = (CinderDisk) getParameters().getDiskInfo();
        cinderDisk.setStorageIds(new ArrayList<>(Collections.singletonList(getStorageDomainId())));
        StorageDomainValidator storageDomainValidator = createStorageDomainValidator();
        CinderDisksValidator cinderDisksValidator = new CinderDisksValidator(cinderDisk);
        return validate(storageDomainValidator.isDomainExistAndActive()) && validate(cinderDisksValidator.validateCinderDiskLimits()) && validate(cinderDisksValidator.validateCinderVolumeTypesExist());
    }
    return true;
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) DiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) VM(org.ovirt.engine.core.common.businessentities.VM) CinderDisksValidator(org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) 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) VmValidator(org.ovirt.engine.core.bll.validator.VmValidator)

Aggregations

DiskValidator (org.ovirt.engine.core.bll.validator.storage.DiskValidator)9 DiskImagesValidator (org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator)4 DiskVmElementValidator (org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator)4 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)4 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 VmValidator (org.ovirt.engine.core.bll.validator.VmValidator)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 Guid (org.ovirt.engine.core.compat.Guid)3 CinderDisksValidator (org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator)1 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)1 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)1