Search in sources :

Example 6 with StorageDomainValidator

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

the class RecoveryStoragePoolCommand method validate.

@Override
protected boolean validate() {
    StoragePoolValidator storagePoolValidator = createStoragePoolValidator();
    if (!validate(storagePoolValidator.exists()) || !validate(new StorageDomainValidator(getStorageDomain()).isInProcess()) || !validate(storagePoolValidator.isAnyDomainInProcess()) || !validate(storagePoolValidator.isNotInStatus(StoragePoolStatus.Uninitialized))) {
        return false;
    }
    if (getStorageDomain() != null && getStorageDomain().getStatus() == StorageDomainStatus.Active) {
        addStorageDomainStatusIllegalMessage();
        return false;
    }
    if (electNewMaster() != null) {
        return failValidation(EngineMessage.STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN);
    }
    StorageDomain domain = loadTargetedMasterDomain();
    if (domain.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL);
    }
    return initializeVds();
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Example 7 with StorageDomainValidator

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

the class ImportValidator method validateStorageExistsForMemoryDisks.

public ValidationResult validateStorageExistsForMemoryDisks(List<Snapshot> snapshots, boolean allowPartial, Map<Guid, String> failedDisksToImport) {
    for (Snapshot snap : snapshots) {
        if (snap.containsMemory()) {
            DiskImage memoryDump = (DiskImage) getDiskDao().get(snap.getMemoryDiskId());
            StorageDomain dumpSd = getStorageDomainDao().getForStoragePool(memoryDump.getStorageIds().get(0), params.getStoragePoolId());
            ValidationResult dumpSdResult = new StorageDomainValidator(dumpSd).isDomainExistAndActive();
            if (!handleStorageValidationResult(dumpSdResult, memoryDump, snap, failedDisksToImport) && !allowPartial) {
                return dumpSdResult;
            }
            DiskImage memoryConf = (DiskImage) getDiskDao().get(snap.getMetadataDiskId());
            StorageDomain confSd = getStorageDomainDao().getForStoragePool(memoryConf.getStorageIds().get(0), params.getStoragePoolId());
            ValidationResult confSdResult = new StorageDomainValidator(confSd).isDomainExistAndActive();
            if (!handleStorageValidationResult(confSdResult, memoryConf, snap, failedDisksToImport) && !allowPartial) {
                return confSdResult;
            }
        }
    }
    return ValidationResult.VALID;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 8 with StorageDomainValidator

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

the class AddDiskCommandTest method mockStorageDomainValidatorWithoutSpace.

private static StorageDomainValidator mockStorageDomainValidatorWithoutSpace() {
    StorageDomainValidator storageDomainValidator = mockStorageDomainValidator();
    when(storageDomainValidator.hasSpaceForNewDisk(any())).thenReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
    return storageDomainValidator;
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 9 with StorageDomainValidator

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

the class AddVmAndCloneImageCommand method buildAndCheckDestStorageDomains.

@Override
protected boolean buildAndCheckDestStorageDomains() {
    if (diskInfoDestinationMap.isEmpty()) {
        List<StorageDomain> domains = storageDomainDao.getAllForStoragePool(getStoragePoolId());
        Map<Guid, StorageDomain> storageDomainsMap = new HashMap<>();
        for (StorageDomain storageDomain : domains) {
            StorageDomainValidator validator = new StorageDomainValidator(storageDomain);
            if (validate(validator.isDomainExistAndActive()) && validate(validator.domainIsValidDestination())) {
                storageDomainsMap.put(storageDomain.getId(), storageDomain);
            }
        }
        for (Disk disk : getDiskImagesToBeCloned()) {
            DiskImage image = (DiskImage) disk;
            for (Guid storageId : image.getStorageIds()) {
                if (storageDomainsMap.containsKey(storageId)) {
                    diskInfoDestinationMap.put(image.getId(), image);
                    break;
                }
            }
        }
        if (getDiskImagesToBeCloned().size() != diskInfoDestinationMap.size()) {
            logErrorOneOrMoreActiveDomainsAreMissing();
            return false;
        }
        List<Guid> storageDomainDest = new ArrayList<>();
        for (DiskImage diskImage : diskInfoDestinationMap.values()) {
            Guid storageDomainId = diskImage.getStorageIds().get(0);
            if (storageDomainDest.contains(storageDomainId)) {
                destStorages.put(storageDomainId, storageDomainsMap.get(storageDomainId));
            }
            storageDomainDest.add(storageDomainId);
        }
        return true;
    }
    return super.buildAndCheckDestStorageDomains();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) 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)

Example 10 with StorageDomainValidator

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

the class RegisterDiskCommand method validate.

@Override
protected boolean validate() {
    refreshDiskImageIfNecessery();
    // Currently this only supports importing DiskImages or CinderDisks and does not work with LunDisks.
    if (getDiskImage().getDiskStorageType() != DiskStorageType.IMAGE && getDiskImage().getDiskStorageType() != DiskStorageType.CINDER) {
        addValidationMessageVariable("diskId", getDiskImage().getId());
        addValidationMessageVariable("storageType", getDiskImage().getDiskStorageType());
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_DISK_STORAGE_TYPE);
        return false;
    }
    if (!validate(new StorageDomainValidator(getStorageDomain()).isDomainExist())) {
        addValidationMessageVariable("diskId", getDiskImage().getId());
        addValidationMessageVariable("domainId", getStorageDomainId());
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_UNAVAILABLE);
        return false;
    }
    if (!getStorageDomain().getStorageDomainType().isDataDomain() && !(getStorageDomain().getStorageDomainType() == StorageDomainType.Volume)) {
        addValidationMessageVariable("domainId", getParameters().getStorageDomainId());
        addValidationMessageVariable("domainType", getStorageDomain().getStorageDomainType());
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_UNSUPPORTED);
        return false;
    }
    if (diskDao.get(getDiskImage().getId()) != null) {
        String diskAlias = ImagesHandler.getDiskAliasWithDefault(getDiskImage(), generateDefaultAliasForRegiteredDisk(Calendar.getInstance()));
        addValidationMessageVariable("diskAliases", diskAlias);
        addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DISKS_LOCKED);
        return false;
    }
    if (!validate(createDiskImagesValidator(getDiskImage()).isQcowVersionSupportedForDcVersion())) {
        return false;
    }
    if (getDiskImage().getDiskStorageType() == DiskStorageType.IMAGE && !setAndValidateDiskProfiles()) {
        return false;
    }
    return true;
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Aggregations

StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)36 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)17 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)16 Guid (org.ovirt.engine.core.compat.Guid)11 ArrayList (java.util.ArrayList)7 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)7 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)6 VmValidator (org.ovirt.engine.core.bll.validator.VmValidator)5 HashMap (java.util.HashMap)4 DiskImagesValidator (org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator)4 DiskValidator (org.ovirt.engine.core.bll.validator.storage.DiskValidator)4 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)4 List (java.util.List)3 Map (java.util.Map)3 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)3 DiskVmElementValidator (org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)2