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.

Revert Ida700555c133e27da2c76357986adfc8193fe89b and re-enables the
test_routerrule_detail test.

Change-Id: I0887b0112f97b537e4c1467c47ab78b1f94f238b
Closes-Bug: 1490403
Closes-Bug: 1490423
This commit is contained in:
Frode Nordahl 2015-08-31 10:25:27 +02:00
parent 183a380da0
commit 749aecda4c
2 changed files with 4 additions and 6 deletions

View File

@ -156,10 +156,10 @@ class RulesGridTab(tabs.Tab):
rd = netaddr.IPNetwork(rd) rd = netaddr.IPNetwork(rd)
dst = netaddr.IPNetwork(dst) dst = netaddr.IPNetwork(dst)
# check if cidrs are affected by rule first # check if cidrs are affected by rule first
if (int(dst.network) >= int(rd.broadcast) or if (int(dst.network) >= int(rd[-1]) or
int(dst.broadcast) <= int(rd.network) or int(dst[-1]) <= int(rd.network) or
int(src.network) >= int(rs.broadcast) or int(src.network) >= int(rs[-1]) or
int(src.broadcast) <= int(rs.network)): int(src[-1]) <= int(rs.network)):
continue continue
# skip matching rules for 'any' and 'external' networks # skip matching rules for 'any' and 'external' networks

View File

@ -15,7 +15,6 @@ import copy
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django import http from django import http
from django.utils import unittest
from mox3.mox import IgnoreArg # noqa from mox3.mox import IgnoreArg # noqa
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
@ -698,7 +697,6 @@ class RouterRuleTests(RouterMixin, test.TestCase):
res, res,
'%s/routers/extensions/routerrules/grid.html' % self.DASHBOARD) '%s/routers/extensions/routerrules/grid.html' % self.DASHBOARD)
@unittest.skip("blocking the gate see bug 1490403")
@test.create_stubs({api.neutron: ('network_list',)}) @test.create_stubs({api.neutron: ('network_list',)})
def test_routerrule_detail(self): def test_routerrule_detail(self):
router = self.routers_with_rules.first() router = self.routers_with_rules.first()