Search in sources :

Example 1 with ReportedConfigurations

use of org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations in project ovirt-engine by oVirt.

the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenDefaultRouteDiffers.

@Test
public void testReportConfigurationsOnHostWhenDefaultRouteDiffers() {
    // cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique.
    iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
    IPv4Address address = new IPv4Address();
    address.setBootProtocol(Ipv4BootProtocol.DHCP);
    testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
    // network has default route role
    NetworkInSyncWithVdsNetworkInterface testedInstance = createTestedInstanceWithSameNonQosValues(true);
    ReportedConfigurations reportedConfigurations = testedInstance.reportConfigurationsOnHost();
    assertThat(reportedConfigurations.isNetworkInSync(), is(false));
    List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList();
    List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/
    address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), "192.168.1.1,2001:0db8:85a3:0000:0000:8a2e:0370:7334", true), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, false, true, false));
    assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
    assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
Also used : ReportedConfigurations(org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations) ReportedConfiguration(org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) Test(org.junit.Test)

Example 2 with ReportedConfigurations

use of org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations in project ovirt-engine by oVirt.

the class ReportedConfigurationsFiller method fillReportedConfigurations.

private void fillReportedConfigurations(Map<String, VdsNetworkInterface> networkNameToNicMap, BusinessEntityMap<Network> networkMap, NetworkAttachment networkAttachment, DnsResolverConfiguration reportedDnsResolverConfiguration, Cluster cluster) {
    Network network = networkMap.get(networkAttachment.getNetworkId());
    VdsNetworkInterface nic = getNicToWhichIsNetworkAttached(networkNameToNicMap, networkMap, networkAttachment);
    if (nic != null) {
        NetworkInSyncWithVdsNetworkInterface isInSync = createNetworkInSyncWithVdsNetworkInterface(networkAttachment, nic, network, reportedDnsResolverConfiguration, cluster);
        ReportedConfigurations reportedConfigurations = isInSync.reportConfigurationsOnHost();
        networkAttachment.setReportedConfigurations(reportedConfigurations);
    }
}
Also used : ReportedConfigurations(org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkInSyncWithVdsNetworkInterface(org.ovirt.engine.core.utils.NetworkInSyncWithVdsNetworkInterface) NetworkInSyncWithVdsNetworkInterface(org.ovirt.engine.core.utils.NetworkInSyncWithVdsNetworkInterface)

Example 3 with ReportedConfigurations

use of org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations in project ovirt-engine by oVirt.

the class NetworkInSyncWithVdsNetworkInterface method reportConfigurationsOnHost.

public ReportedConfigurations reportConfigurationsOnHost() {
    ReportedConfigurations result = new ReportedConfigurations();
    Integer networkMtu = network.getMtu() == 0 ? NetworkUtils.getDefaultMtu() : network.getMtu();
    result.add(ReportedConfigurationType.MTU, iface.getMtu(), networkMtu, isNetworkMtuInSync());
    result.add(ReportedConfigurationType.BRIDGED, iface.isBridged(), network.isVmNetwork());
    result.add(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId());
    result.add(ReportedConfigurationType.SWITCH_TYPE, iface.getReportedSwitchType(), cluster.getRequiredSwitchTypeForCluster());
    addReportedIpv4Configuration(result);
    /**
     * TODO: YZ - uncomment the method call after v4.0 is branched out.
     *
     * Reporting out-of-sync IPv6 configuration is disabled temporary.
     * It's planned to be re-enabled after v4.0-beta is released.
     *
     * addReportedIpv6Configuration(result);
     */
    boolean reportHostQos = ifaceQos != null || hostNetworkQos != null;
    if (reportHostQos) {
        result.add(OUT_AVERAGE_LINK_SHARE, getOutAverageLinkshare(ifaceQos), getOutAverageLinkshare(hostNetworkQos));
        result.add(OUT_AVERAGE_UPPER_LIMIT, getOutAverageUpperlimit(ifaceQos), getOutAverageUpperlimit(hostNetworkQos));
        result.add(OUT_AVERAGE_REAL_TIME, getOutAverageRealtime(ifaceQos), getOutAverageRealtime(hostNetworkQos));
    }
    addDnsConfiguration(result);
    boolean defaultRouteReportedByVdsm = FeatureSupported.isDefaultRouteReportedByVdsm(cluster.getCompatibilityVersion());
    result.add(DEFAULT_ROUTE, iface.isIpv4DefaultRoute(), isDefaultRouteNetwork, !defaultRouteReportedByVdsm || Objects.equals(iface.isIpv4DefaultRoute(), isDefaultRouteNetwork));
    return result;
}
Also used : ReportedConfigurations(org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations)

Example 4 with ReportedConfigurations

use of org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations in project ovirt-engine by oVirt.

the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenSwitchTypeIsOutOfSync.

@Test
public void testReportConfigurationsOnHostWhenSwitchTypeIsOutOfSync() throws Exception {
    cluster.setRequiredSwitchTypeForCluster(SwitchType.OVS);
    ReportedConfigurations reportedConfigurations = createTestedInstance().reportConfigurationsOnHost();
    assertThat(reportedConfigurations.isNetworkInSync(), is(false));
    List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList();
    ReportedConfiguration expectedReportedConfiguration = new ReportedConfiguration(ReportedConfigurationType.SWITCH_TYPE, SwitchType.LEGACY, SwitchType.OVS, false);
    assertThat(reportedConfigurationList.contains(expectedReportedConfiguration), is(true));
}
Also used : ReportedConfigurations(org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations) ReportedConfiguration(org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration) Test(org.junit.Test)

Example 5 with ReportedConfigurations

use of org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations in project ovirt-engine by oVirt.

the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenDnsConfigurationResolverOutOfSync.

@Test
public void testReportConfigurationsOnHostWhenDnsConfigurationResolverOutOfSync() {
    iface.setIpv4DefaultRoute(true);
    // cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique.
    iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
    IPv4Address address = new IPv4Address();
    address.setBootProtocol(Ipv4BootProtocol.DHCP);
    testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
    network.setDnsResolverConfiguration(sampleDnsResolverConfiguration2);
    ReportedConfigurations reportedConfigurations = createTestedInstanceWithSameNonQosValues(true).reportConfigurationsOnHost();
    assertThat(reportedConfigurations.isNetworkInSync(), is(false));
    List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList();
    List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/
    address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), addressesAsString(network.getDnsResolverConfiguration().getNameServers()), false), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, true, true, true));
    assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
    assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
Also used : ReportedConfigurations(org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations) ReportedConfiguration(org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) Test(org.junit.Test)

Aggregations

ReportedConfigurations (org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations)8 ReportedConfiguration (org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration)6 Test (org.junit.Test)5 IPv4Address (org.ovirt.engine.core.common.businessentities.network.IPv4Address)2 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 NetworkInSyncWithVdsNetworkInterface (org.ovirt.engine.core.utils.NetworkInSyncWithVdsNetworkInterface)1