Browse Source

Adapt Neutron database change

Recent Neutron commit moves NetworkSegment table out of the ML2
code tree. This patch adapts this change.

Change-Id: I8d63cfd3cebca97c614ec547fbf58b0bfff4dda7
changes/26/297926/1
zhiyuan_cai 6 years ago
parent
commit
d8d1940b9e
  1. 8
      tricircle/network/plugin.py
  2. 7
      tricircle/tests/unit/network/test_plugin.py

8
tricircle/network/plugin.py

@ -31,12 +31,12 @@ from neutron.db import l3_agentschedulers_db # noqa
from neutron.db import l3_db
from neutron.db import models_v2
from neutron.db import portbindings_db
from neutron.db import segments_db
from neutron.db import sqlalchemyutils
from neutron.extensions import availability_zone as az_ext
from neutron.extensions import external_net
from neutron.extensions import l3
from neutron.plugins.ml2.drivers import type_vlan
import neutron.plugins.ml2.models as ml2_models
import neutronclient.common.exceptions as q_cli_exceptions
from sqlalchemy import sql
@ -706,12 +706,12 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
# allocate a VLAN id for bridge network
phy_net = cfg.CONF.tricircle.bridge_physical_network
with q_ctx.session.begin():
query = q_ctx.session.query(ml2_models.NetworkSegment)
query = q_ctx.session.query(segments_db.NetworkSegment)
query = query.filter_by(network_id=net_id)
if not query.first():
segment = self.vlan_driver.reserve_provider_segment(
q_ctx.session, {'physical_network': phy_net})
record = ml2_models.NetworkSegment(
record = segments_db.NetworkSegment(
id=uuidutils.generate_uuid(),
network_id=net_id,
network_type='vlan',
@ -820,7 +820,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
phy_net = cfg.CONF.tricircle.bridge_physical_network
with q_ctx.session.begin():
query = q_ctx.session.query(ml2_models.NetworkSegment)
query = q_ctx.session.query(segments_db.NetworkSegment)
query = query.filter_by(network_id=t_net['id'])
vlan = query.first().segmentation_id

7
tricircle/tests/unit/network/test_plugin.py

@ -30,6 +30,7 @@ from neutron.db import l3_db
from neutron.db import models_v2
from neutron.extensions import availability_zone as az_ext
from neutron.ipam import subnet_alloc
from neutron import manager
import neutronclient.common.exceptions as q_exceptions
from oslo_config import cfg
@ -87,7 +88,7 @@ RES_MAP = {'networks': TOP_NETS,
'subnetpools': TOP_SUBNETPOOLS,
'subnetpoolprefixes': TOP_SUBNETPOOLPREFIXES,
'ml2_vlan_allocations': TOP_VLANALLOCATIONS,
'ml2_network_segments': TOP_SEGMENTS,
'networksegments': TOP_SEGMENTS,
'externalnetworks': TOP_EXTNETS,
'floatingips': TOP_FLOATINGIPS,
'securitygroups': TOP_SGS,
@ -665,6 +666,9 @@ class PluginTest(unittest.TestCase,
core.ModelBase.metadata.create_all(core.get_engine())
cfg.CONF.register_opts(q_config.core_opts)
self.context = context.Context()
self.save_method = manager.NeutronManager._get_default_service_plugins
manager.NeutronManager._get_default_service_plugins = mock.Mock()
manager.NeutronManager._get_default_service_plugins.return_value = []
def _basic_pod_route_setup(self):
pod1 = {'pod_id': 'pod_id_1',
@ -1827,3 +1831,4 @@ class PluginTest(unittest.TestCase,
for res in RES_LIST:
del res[:]
cfg.CONF.unregister_opts(q_config.core_opts)
manager.NeutronManager._get_default_service_plugins = self.save_method

Loading…
Cancel
Save