summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhsun <zhsun@fiberhome.com>2018-01-15 11:12:40 +0800
committermark mcclain <mark@mcclain.xyz>2018-05-18 00:54:33 +0000
commit6bfbfdbb3db4daf815da6d1a16706f2eec0a2e35 (patch)
treeef14163a5308e3d2d99d62670cc7643f2b3e17c7
parent88a500e2a306ce79ec1d8496d6379118ab737eff (diff)
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 6c4bc1cf0585bdbe3701e0a2a87659881f5b1c73)
Notes
Notes (review): Code-Review+2: Brian Haley <haleyb.dev@gmail.com> Code-Review+2: garyk <gkotton@vmware.com> Workflow+1: garyk <gkotton@vmware.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 24 May 2018 02:35:22 +0000 Reviewed-on: https://review.openstack.org/569295 Project: openstack/neutron Branch: refs/heads/stable/queens
-rw-r--r--neutron/plugins/ml2/drivers/type_vlan.py2
-rw-r--r--neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py16
2 files changed, 17 insertions, 1 deletions
diff --git a/neutron/plugins/ml2/drivers/type_vlan.py b/neutron/plugins/ml2/drivers/type_vlan.py
index 2217740..56ea24f 100644
--- a/neutron/plugins/ml2/drivers/type_vlan.py
+++ b/neutron/plugins/ml2/drivers/type_vlan.py
@@ -130,7 +130,7 @@ class VlanTypeDriver(helpers.SegmentTypeDriver):
130 {'vlan_id': alloc.vlan_id, 130 {'vlan_id': alloc.vlan_id,
131 'physical_network': 131 'physical_network':
132 alloc.physical_network}) 132 alloc.physical_network})
133 ctx.session.delete(alloc) 133 alloc.delete()
134 134
135 def get_type(self): 135 def get_type(self):
136 return p_const.TYPE_VLAN 136 return p_const.TYPE_VLAN
diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
index 550d9cd..4abcf3a 100644
--- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
+++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
@@ -37,6 +37,9 @@ UPDATED_VLAN_RANGES = {
37 PROVIDER_NET: [], 37 PROVIDER_NET: [],
38 TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)], 38 TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)],
39} 39}
40EMPTY_VLAN_RANGES = {
41 PROVIDER_NET: []
42}
40CORE_PLUGIN = 'ml2' 43CORE_PLUGIN = 'ml2'
41 44
42 45
@@ -158,6 +161,19 @@ class VlanTypeTest(testlib_api.SqlTestCase):
158 self.driver._sync_vlan_allocations() 161 self.driver._sync_vlan_allocations()
159 check_in_ranges(UPDATED_VLAN_RANGES) 162 check_in_ranges(UPDATED_VLAN_RANGES)
160 163
164 self.driver.network_vlan_ranges = EMPTY_VLAN_RANGES
165 self.driver._sync_vlan_allocations()
166
167 vlan_min, vlan_max = UPDATED_VLAN_RANGES[TENANT_NET][0]
168 segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
169 api.PHYSICAL_NETWORK: TENANT_NET}
170 segment[api.SEGMENTATION_ID] = vlan_min
171 self.assertIsNone(
172 self._get_allocation(self.context, segment))
173 segment[api.SEGMENTATION_ID] = vlan_max
174 self.assertIsNone(
175 self._get_allocation(self.context, segment))
176
161 def test_reserve_provider_segment(self): 177 def test_reserve_provider_segment(self):
162 segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN, 178 segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
163 api.PHYSICAL_NETWORK: PROVIDER_NET, 179 api.PHYSICAL_NETWORK: PROVIDER_NET,