use of inet.ipaddr.IPAddressString in project onos by opennetworkinglab.
the class KubevirtIpPool method getRangedIps.
/**
* Obtains the IP address list from the given start and end range.
*
* @param start start range
* @param end end range
* @return IP address list from the given start and end range
* @throws AddressStringException exception
*/
public Set<IpAddress> getRangedIps(String start, String end) throws AddressStringException {
Set<IpAddress> ips = new HashSet<>();
IPAddress lower = new IPAddressString(start).toAddress();
IPAddress upper = new IPAddressString(end).toAddress();
IPAddressSeqRange range = lower.toSequentialRange(upper);
for (IPAddress addr : range.getIterable()) {
ips.add(IpAddress.valueOf(addr.toString()));
}
return ips;
}
use of inet.ipaddr.IPAddressString in project so by onap.
the class HeatBridgeImpl method updateLInterfaceIps.
protected void updateLInterfaceIps(final Port port, final LInterface lIf) {
for (IP ip : port.getFixedIps()) {
String ipAddress = ip.getIpAddress();
if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) {
Subnet subnet = osClient.getSubnetById(ip.getSubnetId());
IPAddressString cidr = new IPAddressString(subnet.getCidr());
L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList();
lInterfaceIp.setIsFloating(false);
lInterfaceIp.setL3InterfaceIpv4Address(ipAddress);
lInterfaceIp.setNeutronNetworkId(port.getNetworkId());
lInterfaceIp.setNeutronSubnetId(ip.getSubnetId());
lInterfaceIp.setL3InterfaceIpv4PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString()));
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)), Optional.of(lInterfaceIp));
} else if (InetAddressValidator.getInstance().isValidInet6Address(ipAddress)) {
Subnet subnet = osClient.getSubnetById(ip.getSubnetId());
IPAddressString cidr = new IPAddressString(subnet.getCidr());
L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList();
ipv6.setIsFloating(false);
ipv6.setL3InterfaceIpv6Address(ipAddress);
ipv6.setNeutronNetworkId(port.getNetworkId());
ipv6.setNeutronSubnetId(ip.getSubnetId());
ipv6.setL3InterfaceIpv6PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString()));
transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).l3InterfaceIpv6AddressList(ipAddress)), Optional.of(ipv6));
}
}
}
Aggregations