Search in sources :

Example 6 with IpConfiguration

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

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

the class NetworkAttachmentIpConfigurationValidator method validateIpv6Configuration.

private ValidationResult validateIpv6Configuration(NetworkAttachment networkAttachment) {
    final IpConfiguration ipConfiguration = networkAttachment.getIpConfiguration();
    if (!ipConfiguration.hasIpv6PrimaryAddressSet()) {
        return ValidationResult.VALID;
    }
    IpV6Address ipv6Address = ipConfiguration.getIpv6PrimaryAddress();
    String networkName = networkAttachment.getNetworkName();
    String nicName = networkAttachment.getNicName();
    if (ipv6Address.getBootProtocol() == null) {
        return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_MISSING_BOOT_PROTOCOL, networkName, nicName);
    }
    Ipv6BootProtocol bootProtocol = ipv6Address.getBootProtocol();
    if (bootProtocol == Ipv6BootProtocol.STATIC_IP) {
        if (!validStaticIpv6AddressDetails(ipv6Address)) {
            return incompleteIpConfigurationValidationResult(EngineMessage.NETWORK_ATTACHMENT_IP_CONFIGURATION_STATIC_BOOT_PROTOCOL_MISSING_IP_ADDRESS_DETAILS, networkName, nicName);
        }
    } else {
        if (!isEmptyIpv6AddressDetails(ipv6Address)) {
            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) IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 8 with IpConfiguration

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

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

the class NetworkUtils method createIpConfigurationFromVdsNetworkInterface.

public static IpConfiguration createIpConfigurationFromVdsNetworkInterface(VdsNetworkInterface nic) {
    if (nic == null) {
        return NetworkCommonUtils.createDefaultIpConfiguration();
    }
    final List<IPv4Address> iPv4Addresses = Stream.of(nic).map(new NicToIpv4AddressFunction()).collect(toList());
    final List<IpV6Address> ipV6Addresses = Stream.of(nic).map(new NicToIpv6AddressFunction()).collect(toList());
    IpConfiguration ipConfiguration = new IpConfiguration();
    ipConfiguration.setIPv4Addresses(iPv4Addresses);
    ipConfiguration.setIpV6Addresses(ipV6Addresses);
    return ipConfiguration;
}
Also used : NicToIpv6AddressFunction(org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction) IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address) NicToIpv4AddressFunction(org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction) IPv4Address(org.ovirt.engine.core.common.businessentities.network.IPv4Address)

Example 10 with IpConfiguration

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

the class IpConfigurationCompleterTest method setUp.

@Before
public void setUp() {
    underTest = new IpConfigurationCompleter();
    ipConfiguration = new IpConfiguration();
    networkAttachment = new NetworkAttachment();
    networkAttachment.setIpConfiguration(ipConfiguration);
    networkAttachments = Collections.singleton(networkAttachment);
}
Also used : IpConfiguration(org.ovirt.engine.core.common.businessentities.network.IpConfiguration) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Before(org.junit.Before)

Aggregations

IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)24 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)10 IPv4Address (org.ovirt.engine.core.common.businessentities.network.IPv4Address)6 Test (org.junit.Test)4 IpV6Address (org.ovirt.engine.core.common.businessentities.network.IpV6Address)4 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 NameServer (org.ovirt.engine.core.common.businessentities.network.NameServer)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)2 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)2 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)2 Guid (org.ovirt.engine.core.compat.Guid)2 NicToIpv4AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv4AddressFunction)2 NicToIpv6AddressFunction (org.ovirt.engine.core.utils.network.function.NicToIpv6AddressFunction)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)1 Ipv6BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1