Search in sources :

Example 1 with Ipv6BootProtocol

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

the class NetworkInSyncWithVdsNetworkInterfaceTest method initIpv6ConfigurationBootProtocol.

private void initIpv6ConfigurationBootProtocol(boolean sameBootProtocol) {
    initIpv6Configuration();
    ipv6Address.setBootProtocol(IPV6_BOOT_PROTOCOL);
    Ipv6BootProtocol ifaceBootProtocol = sameBootProtocol ? IPV6_BOOT_PROTOCOL : Ipv6BootProtocol.forValue((IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length);
    iface.setIpv6BootProtocol(ifaceBootProtocol);
}
Also used : Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)

Example 2 with Ipv6BootProtocol

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

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

the class HostNicMapper method mapIpv6ToModel.

private static void mapIpv6ToModel(VdsNetworkInterface entity, HostNic model) {
    BootProtocol ipv6BootProtocol = Ipv6BootProtocolMapper.map(entity.getIpv6BootProtocol());
    if (ipv6BootProtocol != null) {
        model.setIpv6BootProtocol(ipv6BootProtocol);
    }
    if (entity.getIpv6Address() != null || entity.getIpv6Gateway() != null || entity.getIpv6Prefix() != null) {
        final Ip ipv6 = new Ip();
        ipv6.setVersion(IpVersion.V6);
        if (entity.getIpv6Address() != null) {
            ipv6.setAddress(entity.getIpv6Address());
        }
        if (entity.getIpv6Gateway() != null) {
            ipv6.setGateway(entity.getIpv6Gateway());
        }
        if (entity.getIpv6Prefix() != null) {
            ipv6.setNetmask(entity.getIpv6Prefix().toString());
        }
        model.setIpv6(ipv6);
    }
}
Also used : Ip(org.ovirt.engine.api.model.Ip) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) BootProtocol(org.ovirt.engine.api.model.BootProtocol) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)

Example 4 with Ipv6BootProtocol

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

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

the class HostNicMapper method mapIpv6FromModel.

private static void mapIpv6FromModel(HostNic model, VdsNetworkInterface entity) {
    if (model.isSetIpv6()) {
        if (model.getIpv6().isSetAddress()) {
            entity.setIpv6Address(model.getIpv6().getAddress());
        }
        if (model.getIpv6().isSetGateway()) {
            entity.setIpv6Gateway(model.getIpv6().getGateway());
        }
        if (model.getIpv6().isSetNetmask()) {
            try {
                final Integer ipv6Prefix = Integer.valueOf(model.getIpv6().getNetmask());
                entity.setIpv6Prefix(ipv6Prefix);
            } catch (NumberFormatException ignore) {
            }
        }
    }
    if (model.isSetIpv6BootProtocol()) {
        Ipv6BootProtocol ipv6BootProtocol = Ipv6BootProtocolMapper.map(model.getIpv6BootProtocol());
        if (ipv6BootProtocol != null) {
            entity.setIpv6BootProtocol(ipv6BootProtocol);
        }
    }
}
Also used : Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)

Aggregations

Ipv6BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol)10 Ipv4BootProtocol (org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol)3 IpV6Address (org.ovirt.engine.core.common.businessentities.network.IpV6Address)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 BootProtocol (org.ovirt.engine.api.model.BootProtocol)1 Ip (org.ovirt.engine.api.model.Ip)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 VmInitNetwork (org.ovirt.engine.core.common.businessentities.VmInitNetwork)1 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)1