use of org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator in project ovirt-engine by oVirt.
the class ImportValidator method validateStorageExistForUnregisteredEntity.
/**
* Validate the storage domains' existence of the VM's disks. If a storage domain will fail to be active or does not
* exist in the engine, the engine should fail the validation, unless the allowPartial flag is true. Once the
* allowPartial flag is true the operation should not fail and the disk will be removed from the VM's disk list and
* also from the imageToDestinationDomainMap, so the operation will pass the execute phase and import the VM
* partially without the invalid disks.
*
* @param images
* - The images list to validate their storage domains. This list might be filtered if the allowPartial
* flag is true
* @param allowPartial
* - Flag which determine if the VM can be imported partially.
* @param imageToDestinationDomainMap
* - Map from src storage to dst storage which might be filtered if the allowPartial flag is true.
* @return - The validation result.
*/
public ValidationResult validateStorageExistForUnregisteredEntity(List<DiskImage> images, boolean allowPartial, Map<Guid, Guid> imageToDestinationDomainMap, Map<Guid, String> failedDisksToImport) {
for (DiskImage image : new ArrayList<>(images)) {
StorageDomain sd = getStorageDomainDao().getForStoragePool(image.getStorageIds().get(0), params.getStoragePoolId());
ValidationResult result = new StorageDomainValidator(sd).isDomainExistAndActive();
if (!result.isValid()) {
log.error("Storage Domain '{}' with id '{}', could not be found for disk alias '{}' with image id '{}'", sd == null ? null : sd.getStorageName(), image.getStorageIds().get(0), image.getDiskAlias(), image.getId());
if (!allowPartial) {
return result;
}
failedDisksToImport.putIfAbsent(image.getId(), image.getDiskAlias());
imageToDestinationDomainMap.remove(image.getId());
images.remove(image);
}
}
return ValidationResult.VALID;
}
Aggregations