Merge "Fix neutron hang for IPv6 allocation pool update" into stable/juno

This commit is contained in:
Jenkins 2015-01-07 18:12:08 +00:00 committed by Gerrit Code Review
commit 74eff307b7
2 changed files with 58 additions and 22 deletions

View File

@ -267,8 +267,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
for pool in pool_qry.filter_by(subnet_id=subnet['id']):
# Create a set of all addresses in the pool
poolset = netaddr.IPSet(netaddr.iter_iprange(pool['first_ip'],
pool['last_ip']))
poolset = netaddr.IPSet(netaddr.IPRange(pool['first_ip'],
pool['last_ip']))
# Use set difference to find free addresses in the pool
available = poolset - allocations

View File

@ -4058,22 +4058,8 @@ class TestNeutronDbPluginV2(base.BaseTestCase):
self.assertEqual(2, generate.call_count)
rebuild.assert_called_once_with('c', 's')
def test_rebuild_availability_ranges(self):
pools = [{'id': 'a',
'first_ip': '192.168.1.3',
'last_ip': '192.168.1.10'},
{'id': 'b',
'first_ip': '192.168.1.100',
'last_ip': '192.168.1.120'}]
allocations = [{'ip_address': '192.168.1.3'},
{'ip_address': '192.168.1.78'},
{'ip_address': '192.168.1.7'},
{'ip_address': '192.168.1.110'},
{'ip_address': '192.168.1.11'},
{'ip_address': '192.168.1.4'},
{'ip_address': '192.168.1.111'}]
def _validate_rebuild_availability_ranges(self, pools, allocations,
expected):
ip_qry = mock.Mock()
ip_qry.with_lockmode.return_value = ip_qry
ip_qry.filter_by.return_value = allocations
@ -4099,11 +4085,61 @@ class TestNeutronDbPluginV2(base.BaseTestCase):
actual = [[args[0].allocation_pool_id,
args[0].first_ip, args[0].last_ip]
for _name, args, _kwargs in context.session.add.mock_calls]
self.assertEqual(expected, actual)
self.assertEqual([['a', '192.168.1.5', '192.168.1.6'],
['a', '192.168.1.8', '192.168.1.10'],
['b', '192.168.1.100', '192.168.1.109'],
['b', '192.168.1.112', '192.168.1.120']], actual)
def test_rebuild_availability_ranges(self):
pools = [{'id': 'a',
'first_ip': '192.168.1.3',
'last_ip': '192.168.1.10'},
{'id': 'b',
'first_ip': '192.168.1.100',
'last_ip': '192.168.1.120'}]
allocations = [{'ip_address': '192.168.1.3'},
{'ip_address': '192.168.1.78'},
{'ip_address': '192.168.1.7'},
{'ip_address': '192.168.1.110'},
{'ip_address': '192.168.1.11'},
{'ip_address': '192.168.1.4'},
{'ip_address': '192.168.1.111'}]
expected = [['a', '192.168.1.5', '192.168.1.6'],
['a', '192.168.1.8', '192.168.1.10'],
['b', '192.168.1.100', '192.168.1.109'],
['b', '192.168.1.112', '192.168.1.120']]
self._validate_rebuild_availability_ranges(pools, allocations,
expected)
def test_rebuild_ipv6_availability_ranges(self):
pools = [{'id': 'a',
'first_ip': '2001::1',
'last_ip': '2001::50'},
{'id': 'b',
'first_ip': '2001::100',
'last_ip': '2001::ffff:ffff:ffff:fffe'}]
allocations = [{'ip_address': '2001::10'},
{'ip_address': '2001::45'},
{'ip_address': '2001::60'},
{'ip_address': '2001::111'},
{'ip_address': '2001::200'},
{'ip_address': '2001::ffff:ffff:ffff:ff10'},
{'ip_address': '2001::ffff:ffff:ffff:f2f0'}]
expected = [['a', '2001::1', '2001::f'],
['a', '2001::11', '2001::44'],
['a', '2001::46', '2001::50'],
['b', '2001::100', '2001::110'],
['b', '2001::112', '2001::1ff'],
['b', '2001::201', '2001::ffff:ffff:ffff:f2ef'],
['b', '2001::ffff:ffff:ffff:f2f1',
'2001::ffff:ffff:ffff:ff0f'],
['b', '2001::ffff:ffff:ffff:ff11',
'2001::ffff:ffff:ffff:fffe']]
self._validate_rebuild_availability_ranges(pools, allocations,
expected)
class NeutronDbPluginV2AsMixinTestCase(testlib_api.SqlTestCase):