Search in sources :

Example 1 with IpV6Address

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

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

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

the class NetworkAttachmentMapper method mapIpv6AddressAssignment.

static IpV6Address mapIpv6AddressAssignment(IpAddressAssignment ipAddressAssignment) {
    IpV6Address ipV6Address = new IpV6Address();
    if (ipAddressAssignment.isSetAssignmentMethod()) {
        Ipv6BootProtocol assignmentMethod = Ipv6BootProtocolMapper.map(ipAddressAssignment.getAssignmentMethod());
        ipV6Address.setBootProtocol(assignmentMethod);
    }
    if (ipAddressAssignment.isSetIp()) {
        if (ipAddressAssignment.getIp().isSetAddress()) {
            ipV6Address.setAddress(ipAddressAssignment.getIp().getAddress());
        }
        if (ipAddressAssignment.getIp().isSetGateway()) {
            ipV6Address.setGateway(ipAddressAssignment.getIp().getGateway());
        }
        if (ipAddressAssignment.getIp().isSetNetmask()) {
            final String netmask = ipAddressAssignment.getIp().getNetmask();
            final Integer prefix;
            try {
                prefix = Integer.valueOf(netmask);
            } catch (NumberFormatException e) {
                final String message = String.format("IPv6 prefix has to be integer number. '%s' is not a valid value", netmask);
                throw new WebApplicationException(message, e, Response.status(Status.BAD_REQUEST).entity(fault("Invalid value", message)).build());
            }
            ipV6Address.setPrefix(prefix);
        }
    }
    return ipV6Address;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)

Example 4 with IpV6Address

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

the class NicToIpv6AddressFunction method apply.

@Override
public IpV6Address apply(VdsNetworkInterface nic) {
    IpV6Address ipv6Address = new IpV6Address();
    if (nic.getIpv6BootProtocol() == Ipv6BootProtocol.STATIC_IP) {
        ipv6Address.setAddress(nic.getIpv6Address());
        ipv6Address.setPrefix(nic.getIpv6Prefix());
        ipv6Address.setGateway(nic.getIpv6Gateway());
    }
    ipv6Address.setBootProtocol(nic.getIpv6BootProtocol());
    return ipv6Address;
}
Also used : IpV6Address(org.ovirt.engine.core.common.businessentities.network.IpV6Address)

Example 5 with IpV6Address

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

Aggregations

IpV6Address (org.ovirt.engine.core.common.businessentities.network.IpV6Address)19 IPv4Address (org.ovirt.engine.core.common.businessentities.network.IPv4Address)5 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)4 Test (org.junit.Test)3 IpAddressAssignment (org.ovirt.engine.api.model.IpAddressAssignment)2 Ipv6BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 Ip (org.ovirt.engine.api.model.Ip)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)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