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: Iee958314366b9651f79544d80a7a55cf09c73a28
(cherry picked from commit d7d6ffa96e)
changes/79/668279/1 2019.1.0
Nader Lahouti 2 years ago
committed by Nader Lahouti
parent
commit
4f43634316
  1. 16
      networking_arista/ml2/mechanism_arista.py

16
networking_arista/ml2/mechanism_arista.py

@ -20,15 +20,19 @@ from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as n_const
from neutron_lib.plugins.ml2 import api as driver_api
from neutron_lib.services.trunk import constants as trunk_consts
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log as logging
from neutron.db import segments_db
from networking_arista.common import constants as a_const
from networking_arista.common import db_lib
from networking_arista.ml2 import arista_sync
from networking_arista.ml2 import arista_trunk
from networking_arista.ml2.rpc.arista_eapi import AristaRPCWrapperEapi
LOG = logging.getLogger(__name__)
cfg.CONF.import_group('ml2_arista', 'networking_arista.common.config')
@ -350,10 +354,14 @@ class AristaDriver(driver_api.MechanismDriver):
"found", {'port': port_id})
return False
next_segment = context.allocate_dynamic_segment(
{'network_id': context.network.current['id'],
'network_type': n_const.TYPE_VLAN,
'physical_network': physnet})
with lockutils.lock(physnet):
context.allocate_dynamic_segment(
{'network_id': context.network.current['id'],
'network_type': n_const.TYPE_VLAN,
'physical_network': physnet})
next_segment = segments_db.get_dynamic_segment(
context._plugin_context, context.network.current['id'],
physical_network=physnet)
LOG.debug("bind_port for port %(port)s: "
"current_segment=%(current_seg)s, "
"next_segment=%(next_seg)s",

Loading…
Cancel
Save