python 3.3.4 netaddr 7.12 Mac OSX 10.8.5
I have a list of IPNetworks that will not merge with netaddr.cidr_merge() even though some are adjacent. Am I doing something wrong?
import netaddr
from netaddr import IPNetwork
iplist =[
IPNetwork('10.105.205.8/29'),
IPNetwork('10.105.205.16/28'),
IPNetwork('10.105.205.32/27'),
IPNetwork('10.105.205.64/26'),
IPNetwork('10.105.205.128/26'),
IPNetwork('10.105.205.192/28'),
IPNetwork('10.105.205.208/29'),
IPNetwork('10.105.206.48/28'),
IPNetwork('10.105.206.80/28')
]
>>> summary = netaddr.cidr_merge(iplist)
>>> summary == iplist
True
netaddr.cidr_merge(ip_addrs)
A function that accepts an iterable sequence of IP addresses and subnets merging them into the smallest possible list of CIDRs. It merges adjacent subnets where possible, those contained within others and also removes any duplicates.
Parameters: ip_addrs – an iterable sequence of IP addresses and subnets. Returns: a summarized list of IPNetwork objects.