Search in sources :

Example 1 with IPAddressSeqRange

use of inet.ipaddr.IPAddressSeqRange 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;
}
Also used : IPAddressSeqRange(inet.ipaddr.IPAddressSeqRange) IpAddress(org.onlab.packet.IpAddress) IPAddress(inet.ipaddr.IPAddress) HashSet(java.util.HashSet) IPAddressString(inet.ipaddr.IPAddressString)

Aggregations

IPAddress (inet.ipaddr.IPAddress)1 IPAddressSeqRange (inet.ipaddr.IPAddressSeqRange)1 IPAddressString (inet.ipaddr.IPAddressString)1 HashSet (java.util.HashSet)1 IpAddress (org.onlab.packet.IpAddress)1