Fix delete vlan allocation error for ML2

Method "delete()" of ovo object should be invoked.

Closes-bug: #1743425
Change-Id: I942e1a5072ce111beb94ffd6298bb3e23e2bb343
(cherry picked from commit 6c4bc1cf05)
This commit is contained in:
zhsun 2018-01-15 11:12:40 +08:00 committed by mark mcclain
parent 1ba7734082
commit e50a0b7c11
2 changed files with 17 additions and 1 deletions

View File

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

View File

@ -37,6 +37,9 @@ UPDATED_VLAN_RANGES = {
PROVIDER_NET: [],
TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)],
}
EMPTY_VLAN_RANGES = {
PROVIDER_NET: []
}
CORE_PLUGIN = 'ml2'
@ -158,6 +161,19 @@ class VlanTypeTest(testlib_api.SqlTestCase):
self.driver._sync_vlan_allocations()
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):
segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
api.PHYSICAL_NETWORK: PROVIDER_NET,