use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateQosNotPartiallyConfigured.
/**
* Ensure that either none or all of the networks on a single interface have QoS configured on them.
*/
ValidationResult validateQosNotPartiallyConfigured(Collection<NetworkAttachment> attachmentsToConfigure) {
Set<String> someSubInterfacesHaveQos = new HashSet<>();
Set<String> notAllSubInterfacesHaveQos = new HashSet<>();
// first map which interfaces have some QoS configured on them, and which interfaces lack some QoS configuration
for (NetworkAttachment networkAttachment : attachmentsToConfigure) {
Network network = getNetworkRelatedToAttachment(networkAttachment);
if (NetworkUtils.qosConfiguredOnInterface(networkAttachment, network)) {
someSubInterfacesHaveQos.add(networkAttachment.getNicName());
} else {
notAllSubInterfacesHaveQos.add(networkAttachment.getNicName());
}
}
// if any base interface has some sub-interfaces with QoS and some without - this is a partial configuration
for (String ifaceName : someSubInterfacesHaveQos) {
if (notAllSubInterfacesHaveQos.contains(ifaceName)) {
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INTERFACES_WITHOUT_QOS, ReplacementUtils.createSetVariableString("ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INTERFACES_WITHOUT_QOS_LIST", ifaceName));
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class AutodefineExternalNetworkCommand method getPermissionCheckSubjects.
@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
Network network = getNetwork();
Guid networkId = network == null ? null : network.getId();
return Collections.singletonList(new PermissionSubject(networkId, VdcObjectType.Network, getActionType().getActionGroup()));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class GetInterfacesByLabelForNetworkQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Network network = networkDao.get(getParameters().getId());
Set<VdsNetworkInterface> interfacesByLabelForNetwork = new HashSet<>();
if (network == null) {
getQueryReturnValue().setReturnValue(interfacesByLabelForNetwork);
return;
}
List<NetworkCluster> clusters = networkClusterDao.getAllForNetwork(network.getId());
if (clusters.isEmpty()) {
getQueryReturnValue().setReturnValue(interfacesByLabelForNetwork);
return;
}
List<VdsNetworkInterface> labeledNics = new ArrayList<>();
for (NetworkCluster networkCluster : clusters) {
labeledNics.addAll(interfaceDao.getAllInterfacesByLabelForCluster(networkCluster.getClusterId(), network.getLabel()));
}
if (labeledNics.isEmpty()) {
getQueryReturnValue().setReturnValue(interfacesByLabelForNetwork);
return;
}
List<VdsNetworkInterface> networkNics = interfaceDao.getVdsInterfacesByNetworkId(network.getId());
Map<String, VdsNetworkInterface> labeledNicsByName = Entities.entitiesByName(labeledNics);
for (VdsNetworkInterface networkNic : networkNics) {
if (labeledNicsByName.containsKey(NetworkCommonUtils.stripVlan(networkNic))) {
interfacesByLabelForNetwork.add(networkNic);
}
}
getQueryReturnValue().setReturnValue(interfacesByLabelForNetwork);
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class UpdateStoragePoolCommand method validate.
@Override
protected boolean validate() {
StoragePoolValidator spValidator = createStoragePoolValidator();
if (!validate(spValidator.exists())) {
return false;
}
// Name related validations
if (!StringUtils.equals(getOldStoragePool().getName(), getStoragePool().getName()) && !isStoragePoolUnique(getStoragePool().getName())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_POOL_NAME_ALREADY_EXIST);
}
if (!checkStoragePoolNameLengthValid()) {
return false;
}
List<StorageDomainStatic> poolDomains = storageDomainStaticDao.getAllForStoragePool(getStoragePool().getId());
if (getOldStoragePool().isLocal() && !getStoragePool().isLocal() && poolDomains.stream().anyMatch(sdc -> sdc.getStorageType() == StorageType.LOCALFS)) {
return failValidation(EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_POOL_TYPE_WITH_LOCAL);
}
if (!getOldStoragePool().isLocal() && getStoragePool().isLocal()) {
List<Cluster> clusters = clusterDao.getAllForStoragePool(getStoragePool().getId());
if (clusters.size() > 1) {
return failValidation(EngineMessage.CLUSTER_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE);
}
List<VDS> hosts = vdsDao.getAllForStoragePool(getStoragePool().getId());
if (hosts.size() > 1) {
return failValidation(EngineMessage.VDS_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE);
}
}
if (!getOldStoragePool().getCompatibilityVersion().equals(getStoragePool().getCompatibilityVersion())) {
if (!isStoragePoolVersionSupported()) {
return failValidation(VersionSupport.getUnsupportedVersionMessage());
} else // decreasing of compatibility version is allowed under conditions
if (getStoragePool().getCompatibilityVersion().compareTo(getOldStoragePool().getCompatibilityVersion()) < 0) {
if (!poolDomains.isEmpty() && !isCompatibilityVersionChangeAllowedForDomains(poolDomains)) {
return false;
}
List<Network> networks = networkDao.getAllForDataCenter(getStoragePoolId());
for (Network network : networks) {
NetworkValidator validator = getNetworkValidator(network);
if (!getManagementNetworkUtil().isManagementNetwork(network.getId()) || !validator.canNetworkCompatibilityBeDecreased()) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_CANNOT_DECREASE_DATA_CENTER_COMPATIBILITY_VERSION);
}
}
} else if (!checkAllClustersLevel()) {
// Check all clusters has at least the same compatibility version.
return false;
}
}
return validate(spValidator.isNotLocalfsWithDefaultCluster()) && validate(allMacsInEveryClusterCanBeMigratedToAnotherPool());
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class ReportedConfigurationsFillerTest method createNetwork.
private Network createNetwork(String name) {
Network network = new Network();
network.setVmNetwork(false);
network.setId(Guid.newGuid());
network.setName(name);
network.setQosId(Guid.newGuid());
return network;
}
Aggregations