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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations