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
tags/2018.1.9^0
Nader Lahouti 2 months ago
parent
commit
580d44c6e5
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
@@ -352,10 +354,14 @@ class AristaDriver(driver_api.MechanismDriver):
352 354
                       "found", {'port': port_id})
353 355
             return False
354 356
 
355
-        next_segment = context.allocate_dynamic_segment(
356
-            {'network_id': context.network.current['id'],
357
-             'network_type': n_const.TYPE_VLAN,
358
-             'physical_network': physnet})
357
+        with lockutils.lock(physnet):
358
+            context.allocate_dynamic_segment(
359
+                {'network_id': context.network.current['id'],
360
+                 'network_type': n_const.TYPE_VLAN,
361
+                 'physical_network': physnet})
362
+        next_segment = segments_db.get_dynamic_segment(
363
+            context._plugin_context, context.network.current['id'],
364
+            physical_network=physnet)
359 365
         LOG.debug("bind_port for port %(port)s: "
360 366
                   "current_segment=%(current_seg)s, "
361 367
                   "next_segment=%(next_seg)s",

Loading…
Cancel
Save