netaddr 0.7.16 changed the behavior of IPNetworks with /31 and /32
prefixes to make their 'broadcast' attribute return None. This patch
replaces the use of the attribute with a -1 index lookup to get the
last address instead.
Closes-Bug: #
1490380
Change-Id: I97d71c4051882ddd9e496c78cfbce840ad7a2b67
def get_pair(self):
"""Builds an address pair from the first and last addresses. """
+ # TODO(kevinbenton): the callers of this seem only interested in an IP,
+ # so we should just return two IPAddresses.
return (netaddr.IPNetwork("%s/%s" % (self.network, self.prefixlen)),
- netaddr.IPNetwork("%s/%s" % (self.broadcast, self.prefixlen)))
+ netaddr.IPNetwork("%s/%s" % (self[-1], self.prefixlen)))
class LinkLocalAllocator(ItemAllocator):
'scope', scope,
'dev', self.name]
if net.version == 4:
- args += ['brd', str(net.broadcast)]
+ args += ['brd', str(net[-1])]
self._as_root([net.version], tuple(args))
def delete(self, cidr):
# Check that the IP is valid on subnet. This cannot be the
# network or the broadcast address (which exists only in IPv4)
return (ip != net.network
- and (net.version == 6 or ip != net.broadcast)
+ and (net.version == 6 or ip != net[-1])
and net.netmask & ip == net.network)
try:
# Ensure the configured group address/range is valid and multicast
net = netaddr.IPNetwork(cfg.CONF.VXLAN.vxlan_group)
- if not (net.network.is_multicast() and
- net.broadcast.is_multicast()):
+ if not net.is_multicast():
raise ValueError()
# Map the segmentation ID to (one of) the group address(es)
return str(net.network +
net0 = netaddr.IPNetwork(ip_cidr)
net = netaddr.IPNetwork(ip_cidr)
net.value += offset
- if not net0.network < net.ip < net0.broadcast:
+ if not net0.network < net.ip < net0[-1]:
tools.fail(
'Incorrect ip_cidr,offset tuple (%s,%s): "incremented" ip_cidr is '
'outside ip_cidr' % (ip_cidr, offset))