Fix usage of netaddr '.broadcast'
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.
for stable kilo we also fix neutron/db/db_base_plugin_v2.py which had
the checks in neutron/ipam/utils.py for Liberty.
closes-bug: #1490380
(cherry picked from commit 6324f7f23d
)
conflicts:
neutron/ipam/utils.py
neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
Change-Id: I97d71c4051882ddd9e496c78cfbce840ad7a2b67
This commit is contained in:
parent
4c2473c428
commit
cc791b04f0
|
@ -22,8 +22,10 @@ class LinkLocalAddressPair(netaddr.IPNetwork):
|
|||
|
||||
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(object):
|
||||
|
|
|
@ -342,7 +342,7 @@ class IpAddrCommand(IpDeviceCommandBase):
|
|||
'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):
|
||||
|
|
|
@ -343,7 +343,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
|||
# Check that the IP is valid on subnet. This cannot be the
|
||||
# network or the broadcast address
|
||||
if (ip != net.network and
|
||||
ip != net.broadcast and
|
||||
ip != net[-1] and
|
||||
net.netmask & ip == net.network):
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -48,7 +48,7 @@ def increment_ip_cidr(ip_cidr, offset=1):
|
|||
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))
|
||||
|
|
Loading…
Reference in New Issue