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:55:20 +0000
commite50a0b7c118fafcb46a545db28a025ecf3a615d4 (patch)
treed9bffff0da59d762ec1c5249f48e4457615a55aa
parent1ba7734082acaef6e95d489e4c32cea52aa92c4c (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> Code-Review+1: zhangzhaoshan <zhangzhaoshan@inspur.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 02 Jun 2018 01:01:53 +0000 Reviewed-on: https://review.openstack.org/569296 Project: openstack/neutron Branch: refs/heads/stable/pike
-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 622854c..d76832b 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 6b39fc5..afc95b1 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,