use of org.ovirt.engine.core.common.businessentities.network.HostNetworkQos in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method addHostNetworksAndUpdateInterfaces.
private static void addHostNetworksAndUpdateInterfaces(VDS host, Map<String, String> vdsmNameMap, Map<String, Object> struct) {
Map<String, Map<String, Object>> bridges = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_BRIDGES);
final String hostActiveNicName = findActiveNicName(host, bridges);
host.setActiveNic(hostActiveNicName);
// Networks collection (name point to list of nics or bonds)
Map<String, Map<String, Object>> networks = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORKS);
Map<String, VdsNetworkInterface> vdsInterfaces = Entities.entitiesByName(host.getInterfaces());
if (networks != null) {
host.getNetworkNames().clear();
for (Entry<String, Map<String, Object>> entry : networks.entrySet()) {
Map<String, Object> networkProperties = entry.getValue();
String vdsmName = entry.getKey();
String networkName = vdsmNameMap.containsKey(vdsmName) ? vdsmNameMap.get(vdsmName) : vdsmName;
if (networkProperties != null) {
String interfaceName = (String) networkProperties.get(VdsProperties.INTERFACE);
Map<String, Object> bridgeProperties = (bridges == null) ? null : bridges.get(interfaceName);
boolean bridgedNetwork = isBridgedNetwork(networkProperties);
SwitchType switchType = getSwitchType(host.getSupportedClusterVersionsSet().stream().filter(v -> Version.getLast().compareTo(v) >= 0).max(Comparator.naturalOrder()).orElse(Version.getLowest()), networkProperties);
HostNetworkQos qos = new HostNetworkQosMapper(networkProperties).deserialize();
/**
* TODO: remove overly-defensive code in 4.0 - IP address, subnet, gateway and boot protocol should
* only be extracted for bridged networks and from bridge entries (not network entries)
*/
Map<String, Object> effectiveProperties = (bridgedNetwork && bridgeProperties != null) ? bridgeProperties : networkProperties;
String v4addr = extractAddress(effectiveProperties);
String v4Subnet = extractSubnet(effectiveProperties);
String v4gateway = (String) effectiveProperties.get(VdsProperties.GLOBAL_GATEWAY);
boolean v4DefaultRoute = assignBoolValue(effectiveProperties, VdsProperties.IPV4_DEFAULT_ROUTE);
final String rawIpv6Address = getIpv6Address(effectiveProperties);
String v6Addr = extractIpv6Address(rawIpv6Address);
Integer v6Prefix = extractIpv6Prefix(rawIpv6Address);
String v6gateway = (String) effectiveProperties.get(VdsProperties.IPV6_GLOBAL_GATEWAY);
List<VdsNetworkInterface> interfaces = findNetworkInterfaces(vdsInterfaces, interfaceName, bridgeProperties);
for (VdsNetworkInterface iface : interfaces) {
iface.setNetworkName(networkName);
iface.setIpv4Address(v4addr);
iface.setIpv4Subnet(v4Subnet);
iface.setIpv4DefaultRoute(v4DefaultRoute);
iface.setIpv6Address(v6Addr);
iface.setIpv6Prefix(v6Prefix);
iface.setBridged(bridgedNetwork);
iface.setReportedSwitchType(switchType);
iface.setQos(qos);
// set the management ip
if (getManagementNetworkUtil().isManagementNetwork(iface.getNetworkName(), host.getClusterId())) {
iface.setType(iface.getType() | VdsInterfaceType.MANAGEMENT.getValue());
}
if (StringUtils.isNotEmpty(v4gateway)) {
iface.setIpv4Gateway(v4gateway);
}
if (StringUtils.isNotEmpty(v6gateway)) {
iface.setIpv6Gateway(v6gateway);
}
if (bridgedNetwork) {
addBootProtocol(effectiveProperties, iface);
}
}
host.getNetworkNames().add(networkName);
reportInvalidInterfacesForNetwork(interfaces, networkName, host);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.HostNetworkQos in project ovirt-engine by oVirt.
the class AsyncDataProvider method getAllHostNetworkQos.
public void getAllHostNetworkQos(Guid dcId, AsyncQuery<List<HostNetworkQos>> query) {
query.converterCallback = new ListConverter<HostNetworkQos>() {
@Override
public List<HostNetworkQos> convert(List<HostNetworkQos> returnValue) {
List<HostNetworkQos> qosList = super.convert(returnValue);
qosList.add(0, NetworkModel.EMPTY_HOST_NETWORK_QOS);
return qosList;
}
};
Frontend.getInstance().runQuery(QueryType.GetAllQosByStoragePoolIdAndType, new QosQueryParameterBase(dcId, QosType.HOSTNETWORK), query);
}
use of org.ovirt.engine.core.common.businessentities.network.HostNetworkQos in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateQosOverriddenInterfaces.
/**
* Validates that the feature is supported if any QoS configuration was specified, and that the values associated
* with it are valid.
*/
ValidationResult validateQosOverriddenInterfaces() {
for (NetworkAttachment networkAttachment : params.getNetworkAttachments()) {
if (networkAttachment.isQosOverridden()) {
Network network = getNetworkRelatedToAttachment(networkAttachment);
String networkName = network.getName();
HostNetworkQos hostNetworkQos = HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos());
HostNetworkQosValidator qosValidator = createHostNetworkQosValidator(hostNetworkQos);
ValidationResult requiredValuesPresent = qosValidator.requiredQosValuesPresentForOverriding(networkName);
if (!requiredValuesPresent.isValid()) {
return requiredValuesPresent;
}
ValidationResult valuesConsistent = qosValidator.valuesConsistent(networkName);
if (!valuesConsistent.isValid()) {
return valuesConsistent;
}
}
}
return ValidationResult.VALID;
}
use of org.ovirt.engine.core.common.businessentities.network.HostNetworkQos in project ovirt-engine by oVirt.
the class EffectiveHostNetworkQosTest method createHostNetworkQos.
private HostNetworkQos createHostNetworkQos() {
HostNetworkQos hostNetworkQos = new HostNetworkQos();
hostNetworkQos.setId(Guid.newGuid());
return hostNetworkQos;
}
use of org.ovirt.engine.core.common.businessentities.network.HostNetworkQos in project ovirt-engine by oVirt.
the class EffectiveHostNetworkQosTest method testGetQosWhenNetworkAttachmentHasOverriddenQos.
@Test
public void testGetQosWhenNetworkAttachmentHasOverriddenQos() throws Exception {
Network network = createNetworkWithQos(createHostNetworkQos());
NetworkAttachment networkAttachment = createNetworkAttachentWithOverriddenQos();
HostNetworkQos networkAttachmentHostNetworkQos = HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos());
assertThat(effectiveHostNetworkQos.getQos(networkAttachment, network), is(networkAttachmentHostNetworkQos));
verifyNoMoreInteractions(hostNetworkQosDao);
}
Aggregations