use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class NetworkPolicyUnit method filter.
@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
if (hosts == null || hosts.isEmpty()) {
return Collections.emptyList();
}
List<VDS> toRemoveHostList = new ArrayList<>();
List<VmNetworkInterface> vmNICs = vmNetworkInterfaceDao.getAllForVm(vm.getId());
Guid clusterId = hosts.get(0).getClusterId();
List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId);
Map<String, Network> networksByName = Entities.entitiesByName(clusterNetworks);
Map<Guid, List<String>> hostNics = interfaceDao.getHostNetworksByCluster(clusterId);
Network displayNetwork = NetworkUtils.getDisplayNetwork(clusterNetworks);
Map<Guid, VdsNetworkInterface> hostDisplayNics = getDisplayNics(displayNetwork);
for (VDS host : hosts) {
ValidationResult result = validateRequiredNetworksAvailable(host, vm, vmNICs, displayNetwork, networksByName, hostNics.get(host.getId()), hostDisplayNics.get(host.getId()));
if (result.isValid()) {
result = validatePassthroughVnics(vm.getId(), host, vmNICs);
}
if (!result.isValid()) {
toRemoveHostList.add(host);
messages.addMessages(host.getId(), result.getVariableReplacements());
messages.addMessages(host.getId(), result.getMessagesAsStrings());
}
}
hosts.removeAll(toRemoveHostList);
return hosts;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class DiskValidator method isSparsifySupported.
public ValidationResult isSparsifySupported() {
if (disk.getDiskStorageType() != DiskStorageType.IMAGE) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPARSIFY_NOT_SUPPORTED_BY_DISK_STORAGE_TYPE, getDiskAliasVarReplacement(), ReplacementUtils.createSetVariableString("diskStorageType", disk.getDiskStorageType()));
}
if (((DiskImage) disk).getImage().getVolumeType() == VolumeType.Preallocated) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPARSIFY_NOT_SUPPORTED_FOR_PREALLOCATED, getDiskAliasVarReplacement());
}
StorageDomain diskStorageDomain = Injector.get(StorageDomainDao.class).get(((DiskImage) disk).getStorageIds().get(0));
StorageType domainStorageType = diskStorageDomain.getStorageType();
if (!domainStorageType.isFileDomain() && !domainStorageType.isBlockDomain()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPARSIFY_NOT_SUPPORTED_BY_STORAGE_TYPE, getDiskAliasVarReplacement(), getStorageDomainNameVarReplacement(diskStorageDomain), ReplacementUtils.createSetVariableString("storageType", domainStorageType));
}
if (domainStorageType.isBlockDomain() && disk.isWipeAfterDelete()) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPARSIFY_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(diskStorageDomain), getDiskAliasVarReplacement());
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class StorageConnectionValidator method isSameStorageType.
public ValidationResult isSameStorageType(StorageDomain storageDomain) {
StorageType connectionStorageType = connection.getStorageType();
StorageType storageDomainType = storageDomain.getStorageType();
if (!connectionStorageType.equals(storageDomainType)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_NOT_SAME_STORAGE_TYPE);
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class StorageDomainToPoolRelationValidator method validateAmountOfIsoAndExportDomainsInDC.
/**
* Check that we are not trying to attach more than one ISO or export
* domain to the same data center.
*/
public ValidationResult validateAmountOfIsoAndExportDomainsInDC() {
// Nothing to check if the storage domain is not an ISO or export:
if (!isStorageDomainOfTypeIsoOrExport()) {
return ValidationResult.VALID;
}
final StorageDomainType type = storageDomainStatic.getStorageDomainType();
// Check if such a domain type is already present in the pool
boolean hasSuchType = getStorageDomainDao().getAllForStoragePool(storagePool.getId()).stream().anyMatch(a -> a.getStorageDomainType() == type);
// If it's the first domain of that type, we are okay, we can add a new one:
if (!hasSuchType) {
return ValidationResult.VALID;
}
// so when have to prepare a friendly message for the user (see #713160) and fail:
if (type == StorageDomainType.ISO) {
return new ValidationResult(EngineMessage.ERROR_CANNOT_ATTACH_MORE_THAN_ONE_ISO_DOMAIN);
} else {
return new ValidationResult(EngineMessage.ERROR_CANNOT_ATTACH_MORE_THAN_ONE_EXPORT_DOMAIN);
}
}
use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.
the class StorageDomainValidator method isStorageFormatCompatibleWithDomain.
public ValidationResult isStorageFormatCompatibleWithDomain() {
StorageFormatType storageFormat = storageDomain.getStorageFormat();
StorageType storageType = storageDomain.getStorageType();
StorageDomainType storageDomainFunction = storageDomain.getStorageDomainType();
boolean validationSucceeded = true;
if (storageFormat == null) {
validationSucceeded = false;
}
// V2 is applicable only for block data storage domains
if (validationSucceeded && storageFormat == StorageFormatType.V2) {
if (!(storageDomainFunction.isDataDomain() && storageType.isBlockDomain())) {
validationSucceeded = false;
}
}
if (validationSucceeded && storageFormat.compareTo(StorageFormatType.V3) >= 0) {
// Above V3 is applicable only for data storage domains
if (!storageDomainFunction.isDataDomain()) {
validationSucceeded = false;
}
}
return validationSucceeded ? ValidationResult.VALID : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_FORMAT_ILLEGAL_HOST, String.format("$storageFormat %1$s", storageDomain.getStorageFormat()));
}
Aggregations