diff --git a/tricircle/network/plugin.py b/tricircle/network/plugin.py index 5264143..4d282bc 100644 --- a/tricircle/network/plugin.py +++ b/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 diff --git a/tricircle/tests/unit/network/test_plugin.py b/tricircle/tests/unit/network/test_plugin.py index 98939cf..2ed8a0e 100644 --- a/tricircle/tests/unit/network/test_plugin.py +++ b/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