Search in sources :

Example 1 with IPv4Address

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

the class NetworkAttachmentValidatorTest method createNetworkAttachmentWithIpv4Configuration.

private NetworkAttachment createNetworkAttachmentWithIpv4Configuration(Ipv4BootProtocol bootProtocol) {
    IpConfiguration ipConfiguration = new IpConfiguration();
    IPv4Address primaryAddress = new IPv4Address();
    primaryAddress.setAddress(null);
    primaryAddress.setNetmask(null);
    primaryAddress.setBootProtocol(bootProtocol);
    ipConfiguration.getIPv4Addresses().add(primaryAddress);
    NetworkAttachment attachment = new NetworkAttachment();
    attachment.setIpConfiguration(ipConfiguration);
    return attachment;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 2 with IPv4Address

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

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

the class HostNetworkAttachmentsPersisterTest method createIpConfiguration.

private IpConfiguration createIpConfiguration() {
    IpConfiguration result = new IpConfiguration();
    IPv4Address ipv4Address = createIpv4Address();
    IpV6Address ipv6Address = createIpv6Address();
    result.setIPv4Addresses(Collections.singletonList(ipv4Address));
    result.setIpV6Addresses(Collections.singletonList(ipv6Address));
    return result;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address)

Example 4 with IPv4Address

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

the class NetworkAttachmentIpConfigurationValidator method validateIpv4Configuration.

private ValidationResult validateIpv4Configuration(NetworkAttachment networkAttachment) {
    IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
    if (!ipConfiguration.hasIpv4PrimaryAddressSet()) {
        return ValidationResult.VALID;
    }
    IPv4Address iPv4Address = ipConfiguration.getIpv4PrimaryAddress();
    String networkName = networkAttachment.getNetworkName();
    String nicName = networkAttachment.getNicName();
    if (iPv4Address.getBootProtocol() == null) {
        return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
    }
    Ipv4BootProtocol bootProtocol = iPv4Address.getBootProtocol();
    if (bootProtocol == Ipv4BootProtocol.STATIC_IP) {
        if (!validStaticIpv4AddressDetails(iPv4Address)) {
            return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
        }
    } else {
        if (!isEmptyIpv4AddressDetails(iPv4Address)) {
            return new ValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_INCOMPATIBLE_BOOT_PROTOCOL_AND_IP_ADDRESS_DETAILS, ReplacementUtils.createSetVariableString(VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(VAR_INTERFACE_NAME, nicName), ReplacementUtils.createSetVariableString(VAR_BOOT_PROTOCOL, bootProtocol.getDisplayName()));
        }
    }
    return ValidationResult.VALID;
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address)

Example 5 with IPv4Address

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

the class NicToIpv4AddressFunction method apply.

@Override
public IPv4Address apply(VdsNetworkInterface nic) {
    IPv4Address ipv4Address = new IPv4Address();
    if (nic.getIpv4BootProtocol() == Ipv4BootProtocol.STATIC_IP) {
        ipv4Address.setAddress(nic.getIpv4Address());
        ipv4Address.setNetmask(nic.getIpv4Subnet());
        ipv4Address.setGateway(nic.getIpv4Gateway());
    }
    ipv4Address.setBootProtocol(nic.getIpv4BootProtocol());
    return ipv4Address;
}
Also used : 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