Search in sources :

Example 11 with MultipleStorageDomainsValidator

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

the class RunVmValidator method hasSpaceForSnapshots.

/**
 * check that we can create snapshots for all disks
 * return true if all storage domains have enough space to create snapshots for this VM plugged disks
 */
protected ValidationResult hasSpaceForSnapshots() {
    List<Disk> disks = DbFacade.getInstance().getDiskDao().getAllForVm(vm.getId());
    List<DiskImage> allDisks = DisksFilter.filterImageDisks(disks, ONLY_SNAPABLE);
    Set<Guid> sdIds = ImagesHandler.getAllStorageIdsForImageIds(allDisks);
    MultipleStorageDomainsValidator msdValidator = getStorageDomainsValidator(sdIds);
    ValidationResult retVal = msdValidator.allDomainsWithinThresholds();
    if (retVal == ValidationResult.VALID) {
        return msdValidator.allDomainsHaveSpaceForNewDisks(allDisks);
    }
    return retVal;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 12 with MultipleStorageDomainsValidator

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

the class RunVmValidator method validateStorageDomains.

/**
 * Check storage domains. Storage domain status and disk space are checked only for non-HA VMs.
 *
 * @param vm
 *            The VM to run
 * @param isInternalExecution
 *            Command is internal?
 * @param vmImages
 *            The VM's image disks
 * @return <code>true</code> if the VM can be run, <code>false</code> if not
 */
private ValidationResult validateStorageDomains(VM vm, boolean isInternalExecution, List<DiskImage> vmImages) {
    if (vmImages.isEmpty()) {
        return ValidationResult.VALID;
    }
    if (!vm.isAutoStartup() || !isInternalExecution) {
        Set<Guid> storageDomainIds = ImagesHandler.getAllStorageIdsForImageIds(vmImages);
        MultipleStorageDomainsValidator storageDomainValidator = new MultipleStorageDomainsValidator(vm.getStoragePoolId(), storageDomainIds);
        ValidationResult result = storageDomainValidator.allDomainsExistAndActive();
        if (!result.isValid()) {
            return result;
        }
        result = !vm.isAutoStartup() ? storageDomainValidator.allDomainsWithinThresholds() : ValidationResult.VALID;
        if (!result.isValid()) {
            return result;
        }
    }
    return ValidationResult.VALID;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Aggregations

MultipleStorageDomainsValidator (org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator)12 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)9 Guid (org.ovirt.engine.core.compat.Guid)8 VmValidator (org.ovirt.engine.core.bll.validator.VmValidator)5 DiskImagesValidator (org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator)5 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)5 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 ArrayList (java.util.ArrayList)2 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)2 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)2 CinderDisksValidator (org.ovirt.engine.core.bll.validator.storage.CinderDisksValidator)1 DiskSnapshotsValidator (org.ovirt.engine.core.bll.validator.storage.DiskSnapshotsValidator)1 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)1 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1