Search in sources :

Example 21 with IPv4Address

use of org.ovirt.engine.core.common.businessentities.network.IPv4Address 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)

Example 22 with IPv4Address

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

the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenIpv4BootProtocolNotStatic.

@Test
public void testReportConfigurationsOnHostWhenIpv4BootProtocolNotStatic() {
    initIpv4ConfigurationBootProtocolAddress(Ipv4BootProtocol.NONE, false);
    initIpv4ConfigurationBootProtocolNetmask(Ipv4BootProtocol.NONE, false);
    initIpv4ConfigurationBootProtocolGateway(Ipv4BootProtocol.NONE, false);
    NetworkInSyncWithVdsNetworkInterface testedInstanceWithSameNonQosValues = createTestedInstanceWithSameNonQosValues();
    List<ReportedConfiguration> reportedConfigurationList = testedInstanceWithSameNonQosValues.reportConfigurationsOnHost().getReportedConfigurationList();
    IPv4Address primaryAddress = this.testedNetworkAttachment.getIpConfiguration().getIpv4PrimaryAddress();
    List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(createBasicAndQosReportedConfigurations(), defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), primaryAddress.getBootProtocol().name(), true));
    assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true));
    assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
Also used : ReportedConfiguration(org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) Test(org.junit.Test)

Example 23 with IPv4Address

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

the class NetworkInSyncWithVdsNetworkInterfaceTest method testDnsResolverConfigurationInSyncWithHostWhenDhcpIsUsed.

@Test
public void testDnsResolverConfigurationInSyncWithHostWhenDhcpIsUsed() {
    iface.setIpv4DefaultRoute(false);
    network.setDnsResolverConfiguration(sampleDnsResolverConfiguration2);
    testedNetworkAttachment.setDnsResolverConfiguration(null);
    iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP);
    IPv4Address address = new IPv4Address();
    address.setBootProtocol(Ipv4BootProtocol.DHCP);
    testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address));
    assertThat(createTestedInstance(true, sampleDnsResolverConfiguration).isNetworkInSync(), is(false));
}
Also used : IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) Test(org.junit.Test)

Example 24 with IPv4Address

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

the class NetworkInSyncWithVdsNetworkInterfaceTest method testDnsResolverConfiguration.

private void testDnsResolverConfiguration(DnsResolverConfiguration vdsDnsResolver, DnsResolverConfiguration networkDnsResolver, DnsResolverConfiguration attachmentDnsResolver, boolean expectedInSync) {
    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(networkDnsResolver);
    testedNetworkAttachment.setDnsResolverConfiguration(attachmentDnsResolver);
    assertThat(createTestedInstance(true, vdsDnsResolver).isNetworkInSync(), is(expectedInSync));
}
Also used : IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address)

Example 25 with IPv4Address

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

the class NetworkInSyncWithVdsNetworkInterfaceTest method testReportConfigurationsOnHostWhenIpv4BootProtocolStatic.

private void testReportConfigurationsOnHostWhenIpv4BootProtocolStatic(boolean syncAddress, boolean syncNetmask, boolean syncGateway) {
    initIpv4ConfigurationBootProtocolAddress(Ipv4BootProtocol.STATIC_IP, syncAddress);
    initIpv4ConfigurationBootProtocolNetmask(Ipv4BootProtocol.STATIC_IP, syncNetmask);
    initIpv4ConfigurationBootProtocolGateway(Ipv4BootProtocol.STATIC_IP, syncGateway);
    NetworkInSyncWithVdsNetworkInterface testedInstanceWithSameNonQosValues = createTestedInstanceWithSameNonQosValues();
    List<ReportedConfiguration> reportedConfigurationList = testedInstanceWithSameNonQosValues.reportConfigurationsOnHost().getReportedConfigurationList();
    IPv4Address primaryAddress = this.testedNetworkAttachment.getIpConfiguration().getIpv4PrimaryAddress();
    List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations(createBasicAndQosReportedConfigurations(), defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), primaryAddress.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.IPV4_NETMASK, iface.getIpv4Subnet(), primaryAddress.getNetmask(), syncNetmask), new ReportedConfiguration(ReportedConfigurationType.IPV4_ADDRESS, iface.getIpv4Address(), primaryAddress.getAddress(), syncAddress), new ReportedConfiguration(ReportedConfigurationType.IPV4_GATEWAY, iface.getIpv4Gateway(), primaryAddress.getGateway(), syncGateway));
    for (ReportedConfiguration expectedReportedConfiguration : expectedReportedConfigurations) {
        assertThat("expected configuration not reported:" + expectedReportedConfiguration, reportedConfigurationList.contains(expectedReportedConfiguration), is(true));
    }
    assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size()));
}
Also used : ReportedConfiguration(org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address)

Aggregations

IPv4Address (org.ovirt.engine.core.common.businessentities.network.IPv4Address)25 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)6 Test (org.junit.Test)5 IpV6Address (org.ovirt.engine.core.common.businessentities.network.IpV6Address)5 ReportedConfiguration (org.ovirt.engine.core.common.businessentities.network.ReportedConfiguration)4 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 ReportedConfigurations (org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 NicToIpv4AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction)1 NicToIpv6AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction)1 NetworkParameters (org.ovirt.engine.ui.uicommonweb.models.hosts.NetworkParameters)1