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;
}
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;
}
Aggregations