Search in sources :

Example 16 with StorageDomainValidator

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

the class ImportRepoImageCommand method validateSpaceRequirements.

protected boolean validateSpaceRequirements(DiskImage diskImage) {
    // Added for validation purposes.
    diskImage.getSnapshots().add(diskImage);
    StorageDomainValidator sdValidator = createStorageDomainValidator();
    boolean result = validate(sdValidator.isDomainExistAndActive()) && validate(sdValidator.isDomainWithinThresholds()) && validate(sdValidator.hasSpaceForClonedDisk(diskImage));
    diskImage.getSnapshots().remove(diskImage);
    return result;
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Example 17 with StorageDomainValidator

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

the class StorageDomainSpaceRequirementsFilter method test.

@Override
public boolean test(StorageDomain storageDomain) {
    memoryStorageHandler.updateDisksStorage(storageDomain, memoryDisks);
    StorageDomainValidator storageDomainValidator = getStorageDomainValidator(storageDomain);
    return storageDomainValidator.isDomainWithinThresholds().isValid() && storageDomainValidator.hasSpaceForClonedDisks(memoryDisks).isValid();
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Example 18 with StorageDomainValidator

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

the class HotPlugDiskToVmCommand method imageStorageValidation.

private boolean imageStorageValidation() {
    // so we don't need to check the storage domain activity.
    if (getDisk().getDiskStorageType() != DiskStorageType.IMAGE || !getVm().getStatus().isRunningOrPaused()) {
        return true;
    }
    DiskImage diskImage = (DiskImage) getDisk();
    StorageDomain storageDomain = storageDomainDao.getForStoragePool(diskImage.getStorageIds().get(0), diskImage.getStoragePoolId());
    StorageDomainValidator storageDomainValidator = getStorageDomainValidator(storageDomain);
    return validate(storageDomainValidator.isDomainExistAndActive()) && validate(storageDomainValidator.isNotBackupDomain());
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 19 with StorageDomainValidator

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

the class MoveOrCopyDiskCommand method validateDestStorage.

protected boolean validateDestStorage() {
    StorageDomainValidator validator = new StorageDomainValidator(getStorageDomain());
    if (!validate(validator.isDomainExistAndActive()) || !validate(validator.domainIsValidDestination())) {
        return false;
    }
    // Validate shareable disks moving/copying
    boolean moveOrCopy = isMoveOperation() || isCopyOperation();
    if (moveOrCopy && getImage().isShareable() && getStorageDomain().getStorageType() == StorageType.GLUSTERFS) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_CANT_MOVE_SHAREABLE_DISK_TO_GLUSTERFS, String.format("$%1$s %2$s", "diskAlias", getImage().getDiskAlias()));
    }
    if (isMoveOperation()) {
        if (getImage().getStorageIds().contains(getStorageDomainId())) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_DESTINATION_STORAGE_DOMAIN_ALREADY_CONTAINS_THE_DISK);
        }
    }
    return true;
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)

Example 20 with StorageDomainValidator

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

the class MoveOrCopyDiskCommand method validateSourceStorageDomain.

/**
 * Validate a source storage domain of image, when a source storage domain is not provided
 * any of the domains image will be used
 */
protected boolean validateSourceStorageDomain() {
    Guid sourceDomainId = getParameters().getSourceDomainId();
    if (sourceDomainId == null || Guid.Empty.equals(sourceDomainId)) {
        sourceDomainId = getImage().getStorageIds().get(0);
        getParameters().setSourceDomainId(sourceDomainId);
    } else {
        if (!getImage().getStorageIds().contains(sourceDomainId)) {
            return failValidation(EngineMessage.ACTION_TYPE_FAILED_SOURCE_STORAGE_DOMAIN_DOES_CONTAINS_THE_DISK);
        }
    }
    StorageDomainValidator validator = new StorageDomainValidator(storageDomainDao.getForStoragePool(sourceDomainId, getImage().getStoragePoolId()));
    return validate(validator.isDomainExistAndActive());
}
Also used : StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) Guid(org.ovirt.engine.core.compat.Guid)

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