Browse Source

Get next segment from NetworkSegment DB

Query one more time from NetworkSegment for a dynamic segment added
to the table instead of relying on what reserve_provider_segment returns

Change-Id: Idb9bdfc08767b0f17815f4189501df4307844e34
(cherry picked from commit 580d44c6e5)
tags/2018.2.4^0
Nader Lahouti 2 months ago
parent
commit
f96ef78ac6
1 changed files with 10 additions and 4 deletions
  1. 10
    4
      networking_arista/ml2/mechanism_arista.py

+ 10
- 4
networking_arista/ml2/mechanism_arista.py View File

@@ -19,9 +19,11 @@ from multiprocessing import Queue
19 19
 from neutron_lib.api.definitions import portbindings
20 20
 from neutron_lib import constants as n_const
21 21
 from neutron_lib.plugins.ml2 import api as driver_api
22
+from oslo_concurrency import lockutils
22 23
 from oslo_config import cfg
23 24
 from oslo_log import log as logging
24 25
 
26
+from neutron.db import segments_db
25 27
 from neutron.services.trunk import constants as trunk_consts
26 28
 
27 29
 from networking_arista.common import constants as a_const
@@ -351,10 +353,14 @@ class AristaDriver(driver_api.MechanismDriver):
351 353
                       "found", {'port': port_id})
352 354
             return False
353 355
 
354
-        next_segment = context.allocate_dynamic_segment(
355
-            {'network_id': context.network.current['id'],
356
-             'network_type': n_const.TYPE_VLAN,
357
-             'physical_network': physnet})
356
+        with lockutils.lock(physnet):
357
+            context.allocate_dynamic_segment(
358
+                {'network_id': context.network.current['id'],
359
+                 'network_type': n_const.TYPE_VLAN,
360
+                 'physical_network': physnet})
361
+        next_segment = segments_db.get_dynamic_segment(
362
+            context._plugin_context, context.network.current['id'],
363
+            physical_network=physnet)
358 364
         LOG.debug("bind_port for port %(port)s: "
359 365
                   "current_segment=%(current_seg)s, "
360 366
                   "next_segment=%(next_seg)s",

Loading…
Cancel
Save