Search in sources :

Example 21 with HostNetworkQos

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);
            }
        }
    }
}
Also used : RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) Matcher(java.util.regex.Matcher) EnumUtils(org.ovirt.engine.core.common.utils.EnumUtils) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Path(java.nio.file.Path) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) Set(java.util.Set) CpuStatistics(org.ovirt.engine.core.common.businessentities.CpuStatistics) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) AutoNumaBalanceStatus(org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) Stream(java.util.stream.Stream) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) Injector(org.ovirt.engine.core.di.Injector) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) NetworkCommonUtils(org.ovirt.engine.core.common.utils.NetworkCommonUtils) VmExitStatus(org.ovirt.engine.core.common.businessentities.VmExitStatus) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) BondMode(org.ovirt.engine.core.common.businessentities.network.BondMode) SessionState(org.ovirt.engine.core.common.businessentities.SessionState) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) NetworkStatisticsBuilder(org.ovirt.engine.core.vdsbroker.NetworkStatisticsBuilder) OsType(org.ovirt.engine.core.common.businessentities.OsType) SimpleDateFormat(java.text.SimpleDateFormat) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) LinkedHashSet(java.util.LinkedHashSet) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) VM(org.ovirt.engine.core.common.businessentities.VM) LeaseStatus(org.ovirt.engine.core.common.businessentities.LeaseStatus) NetworkInterface(org.ovirt.engine.core.common.businessentities.network.NetworkInterface) Paths(java.nio.file.Paths) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) Date(java.util.Date) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) LoggerFactory(org.slf4j.LoggerFactory) VdsTransparentHugePagesState(org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) InterfaceByAddressPredicate(org.ovirt.engine.core.utils.network.predicate.InterfaceByAddressPredicate) SwitchType(org.ovirt.engine.core.common.network.SwitchType) KdumpStatus(org.ovirt.engine.core.common.businessentities.KdumpStatus) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) ParseException(java.text.ParseException) Version(org.ovirt.engine.core.compat.Version) DateFormat(java.text.DateFormat) VdsInterfaceType(org.ovirt.engine.core.common.businessentities.network.VdsInterfaceType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmPauseStatus(org.ovirt.engine.core.common.businessentities.VmPauseStatus) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Predicate(java.util.function.Predicate) ManagementNetworkUtil(org.ovirt.engine.core.bll.network.cluster.ManagementNetworkUtil) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) IpAddressPredicate(org.ovirt.engine.core.utils.network.predicate.IpAddressPredicate) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Entry(java.util.Map.Entry) AuditLogType(org.ovirt.engine.core.common.AuditLogType) Pattern(java.util.regex.Pattern) NumaUtils(org.ovirt.engine.core.utils.NumaUtils) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmBalloonInfo(org.ovirt.engine.core.common.businessentities.VmBalloonInfo) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Entities(org.ovirt.engine.core.common.businessentities.Entities) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) SizeConverter(org.ovirt.engine.core.common.utils.SizeConverter) VmBlockJobType(org.ovirt.engine.core.common.businessentities.VmBlockJobType) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Config(org.ovirt.engine.core.common.config.Config) VmJobState(org.ovirt.engine.core.common.businessentities.VmJobState) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) DecimalFormat(java.text.DecimalFormat) GuestContainer(org.ovirt.engine.core.common.businessentities.GuestContainer) V2VJobInfo(org.ovirt.engine.core.common.businessentities.V2VJobInfo) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) VmExitReason(org.ovirt.engine.core.common.businessentities.VmExitReason) SerializationFactory(org.ovirt.engine.core.utils.SerializationFactory) NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics) Comparator(java.util.Comparator) NumaNodeStatistics(org.ovirt.engine.core.common.businessentities.NumaNodeStatistics) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) SwitchType(org.ovirt.engine.core.common.network.SwitchType) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with HostNetworkQos

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);
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) QosQueryParameterBase(org.ovirt.engine.core.common.queries.QosQueryParameterBase) ArrayList(java.util.ArrayList) List(java.util.List)

Example 23 with HostNetworkQos

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;
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) HostNetworkQosValidator(org.ovirt.engine.core.bll.validator.HostNetworkQosValidator)

Example 24 with HostNetworkQos

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;
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)

Example 25 with 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);
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Aggregations

HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)32 AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)11 Network (org.ovirt.engine.core.common.businessentities.network.Network)9 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)7 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 Test (org.junit.Test)5 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 Guid (org.ovirt.engine.core.compat.Guid)3 StringUtils (org.apache.commons.lang.StringUtils)2 Before (org.junit.Before)2 HostNic (org.ovirt.engine.api.model.HostNic)2 NameServer (org.ovirt.engine.core.common.businessentities.network.NameServer)2 VdsNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)2 EffectiveHostNetworkQos (org.ovirt.engine.core.vdsbroker.EffectiveHostNetworkQos)2 Path (java.nio.file.Path)1