Merge "Fix delete vlan allocation error for ML2"

This commit is contained in:
Zuul 2018-03-09 15:29:19 +00:00 committed by Gerrit Code Review
commit ed9457fc2b
2 changed files with 17 additions and 1 deletions

View File

@ -130,7 +130,7 @@ class VlanTypeDriver(helpers.SegmentTypeDriver):
{'vlan_id': alloc.vlan_id, {'vlan_id': alloc.vlan_id,
'physical_network': 'physical_network':
alloc.physical_network}) alloc.physical_network})
ctx.session.delete(alloc) alloc.delete()
def get_type(self): def get_type(self):
return p_const.TYPE_VLAN return p_const.TYPE_VLAN

View File

@ -37,6 +37,9 @@ UPDATED_VLAN_RANGES = {
PROVIDER_NET: [], PROVIDER_NET: [],
TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)], TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)],
} }
EMPTY_VLAN_RANGES = {
PROVIDER_NET: []
}
CORE_PLUGIN = 'ml2' CORE_PLUGIN = 'ml2'
@ -158,6 +161,19 @@ class VlanTypeTest(testlib_api.SqlTestCase):
self.driver._sync_vlan_allocations() self.driver._sync_vlan_allocations()
check_in_ranges(UPDATED_VLAN_RANGES) check_in_ranges(UPDATED_VLAN_RANGES)
self.driver.network_vlan_ranges = EMPTY_VLAN_RANGES
self.driver._sync_vlan_allocations()
vlan_min, vlan_max = UPDATED_VLAN_RANGES[TENANT_NET][0]
segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
api.PHYSICAL_NETWORK: TENANT_NET}
segment[api.SEGMENTATION_ID] = vlan_min
self.assertIsNone(
self._get_allocation(self.context, segment))
segment[api.SEGMENTATION_ID] = vlan_max
self.assertIsNone(
self._get_allocation(self.context, segment))
def test_reserve_provider_segment(self): def test_reserve_provider_segment(self):
segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN, segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
api.PHYSICAL_NETWORK: PROVIDER_NET, api.PHYSICAL_NETWORK: PROVIDER_NET,