Browse Source

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)
tags/11.0.5
zhsun 1 year ago
parent
commit
e50a0b7c11

+ 1
- 1
neutron/plugins/ml2/drivers/type_vlan.py View File

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

+ 16
- 0
neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py View File

@@ -37,6 +37,9 @@ UPDATED_VLAN_RANGES = {
37 37
     PROVIDER_NET: [],
38 38
     TENANT_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)],
39 39
 }
40
+EMPTY_VLAN_RANGES = {
41
+    PROVIDER_NET: []
42
+}
40 43
 CORE_PLUGIN = 'ml2'
41 44
 
42 45
 
@@ -158,6 +161,19 @@ class VlanTypeTest(testlib_api.SqlTestCase):
158 161
         self.driver._sync_vlan_allocations()
159 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 177
     def test_reserve_provider_segment(self):
162 178
         segment = {api.NETWORK_TYPE: p_const.TYPE_VLAN,
163 179
                    api.PHYSICAL_NETWORK: PROVIDER_NET,

Loading…
Cancel
Save