From 326b85dd6154048b1671732d2d7df8deb8b99207 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Wed, 19 Feb 2014 15:08:54 -0800 Subject: [PATCH] Plugins should call __init__ of db_base_plugin for db.configure Currently each plugin calls db.configure() within the plugin's __init__ class or defines an initialize() method that's sole job is to call this method. Instead we should just call the super method of a plugin so that db.configure() is called for us out of the db_base_plugin class. Note: the only reason why I'm making this change is that I want to add something to the __init__() class of the db_base_plugin that's needed for the nova-event-callback blueprint and adding it in the base class of init looks to be the best place. Change-Id: Iec3c912735021ceb90f657108aad3a57460d66e7 Closes-bug: #1282303 --- neutron/db/db_base_plugin_v2.py | 4 ---- neutron/plugins/bigswitch/plugin.py | 5 ++--- neutron/plugins/brocade/NeutronPlugin.py | 2 +- neutron/plugins/cisco/db/n1kv_db_v2.py | 5 ----- neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py | 2 +- neutron/plugins/linuxbridge/db/l2network_db_v2.py | 4 ---- neutron/plugins/linuxbridge/lb_neutron_plugin.py | 2 +- neutron/plugins/metaplugin/meta_neutron_plugin.py | 3 +-- neutron/plugins/metaplugin/proxy_neutron_plugin.py | 3 +-- neutron/plugins/midonet/plugin.py | 3 +-- neutron/plugins/ml2/db.py | 4 ---- neutron/plugins/ml2/plugin.py | 2 +- neutron/plugins/mlnx/db/mlnx_db_v2.py | 4 ---- neutron/plugins/mlnx/mlnx_plugin.py | 2 +- neutron/plugins/nec/db/api.py | 4 ---- neutron/plugins/nec/nec_plugin.py | 3 +-- neutron/plugins/nicira/NeutronPlugin.py | 4 +--- neutron/plugins/openvswitch/ovs_db_v2.py | 4 ---- neutron/plugins/openvswitch/ovs_neutron_plugin.py | 2 +- .../plumgrid/plumgrid_plugin/plumgrid_plugin.py | 5 +---- neutron/plugins/ryu/ryu_neutron_plugin.py | 2 +- neutron/tests/unit/cisco/n1kv/test_n1kv_db.py | 12 ++++++------ neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py | 2 +- neutron/tests/unit/linuxbridge/test_lb_db.py | 4 ++-- neutron/tests/unit/ml2/test_type_gre.py | 5 ++--- neutron/tests/unit/ml2/test_type_vxlan.py | 5 ++--- neutron/tests/unit/mlnx/test_mlnx_db.py | 4 ++-- neutron/tests/unit/nec/test_ofc_manager.py | 3 ++- neutron/tests/unit/openvswitch/test_ovs_db.py | 6 +++--- neutron/tests/unit/test_quota_ext.py | 3 +-- 30 files changed, 36 insertions(+), 77 deletions(-) diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index d6adceef3..33cac83f8 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -224,10 +224,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2, __native_sorting_support = True def __init__(self): - # NOTE(jkoelker) This is an incomplete implementation. Subclasses - # must override __init__ and setup the database - # and not call into this class's __init__. - # This connection is setup as memory for the tests. db.configure_db() @classmethod diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index d0bc7d46e..ef3933858 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -57,7 +57,6 @@ from neutron.common import topics from neutron import context as qcontext from neutron.db import agents_db from neutron.db import agentschedulers_db -from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import dhcp_rpc_base from neutron.db import external_net_db @@ -102,6 +101,7 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2, servers = None def __init__(self, server_timeout=None): + super(NeutronRestProxyV2Base, self).__init__() # This base class is not intended to be instantiated directly. # Extending class should set ServerPool. if not self.servers: @@ -321,11 +321,10 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base, "dhcp_agent_scheduler", "agent"] def __init__(self, server_timeout=None): + super(NeutronRestProxyV2, self).__init__() LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'), version_string_with_vcs()) pl_config.register_config() - # init DB, proxy's persistent store defaults to in-memory sql-lite DB - db.configure_db() # Include the BigSwitch Extensions path in the api_extensions neutron_extensions.append_api_extensions_path(extensions.__path__) diff --git a/neutron/plugins/brocade/NeutronPlugin.py b/neutron/plugins/brocade/NeutronPlugin.py index b49a6bafe..f5a04ad20 100644 --- a/neutron/plugins/brocade/NeutronPlugin.py +++ b/neutron/plugins/brocade/NeutronPlugin.py @@ -225,6 +225,7 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2, Specify switch address and db configuration. """ + super(BrocadePluginV2, self).__init__() self.supported_extension_aliases = ["binding", "security-group", "external-net", "router", "extraroute", "agent", @@ -235,7 +236,6 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2, physical_interface) self.base_binding_dict = self._get_base_binding_dict() portbindings_base.register_port_dict_function() - db.configure_db() self.ctxt = context.get_admin_context() self.ctxt.session = db.get_session() self._vlan_bitmap = vbm.VlanBitmap(self.ctxt) diff --git a/neutron/plugins/cisco/db/n1kv_db_v2.py b/neutron/plugins/cisco/db/n1kv_db_v2.py index 7c7de737d..01bd40966 100644 --- a/neutron/plugins/cisco/db/n1kv_db_v2.py +++ b/neutron/plugins/cisco/db/n1kv_db_v2.py @@ -35,11 +35,6 @@ from neutron.plugins.cisco.db import n1kv_models_v2 LOG = logging.getLogger(__name__) -def initialize(): - """Initialize the database.""" - db.configure_db() - - def del_trunk_segment_binding(db_session, trunk_segment_id, segment_pairs): """ Delete a trunk network binding. diff --git a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py index 3c7acb822..682edd740 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py +++ b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py @@ -102,7 +102,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, 1. Initialize Nexus1000v and Credential DB 2. Establish communication with Cisco Nexus1000V """ - n1kv_db_v2.initialize() + super(N1kvNeutronPluginV2, self).__init__() c_cred.Store.initialize() self._initialize_network_ranges() self._setup_vsm() diff --git a/neutron/plugins/linuxbridge/db/l2network_db_v2.py b/neutron/plugins/linuxbridge/db/l2network_db_v2.py index 786fe841a..819d16a32 100644 --- a/neutron/plugins/linuxbridge/db/l2network_db_v2.py +++ b/neutron/plugins/linuxbridge/db/l2network_db_v2.py @@ -29,10 +29,6 @@ from neutron.plugins.linuxbridge.db import l2network_models_v2 LOG = logging.getLogger(__name__) -def initialize(): - db.configure_db() - - def sync_network_states(network_vlan_ranges): """Synchronize network_states table with current configured VLAN ranges.""" diff --git a/neutron/plugins/linuxbridge/lb_neutron_plugin.py b/neutron/plugins/linuxbridge/lb_neutron_plugin.py index 995b2fe78..c06ce6a76 100644 --- a/neutron/plugins/linuxbridge/lb_neutron_plugin.py +++ b/neutron/plugins/linuxbridge/lb_neutron_plugin.py @@ -252,12 +252,12 @@ class LinuxBridgePluginV2(db_base_plugin_v2.NeutronDbPluginV2, return self._aliases def __init__(self): + super(LinuxBridgePluginV2, self).__init__() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_BRIDGE, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} - db.initialize() self._parse_network_vlan_ranges() db.sync_network_states(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.VLANS.tenant_network_type diff --git a/neutron/plugins/metaplugin/meta_neutron_plugin.py b/neutron/plugins/metaplugin/meta_neutron_plugin.py index fb4ad8877..1f1a38606 100644 --- a/neutron/plugins/metaplugin/meta_neutron_plugin.py +++ b/neutron/plugins/metaplugin/meta_neutron_plugin.py @@ -50,6 +50,7 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2, extraroute_db.ExtraRoute_db_mixin): def __init__(self, configfile=None): + super(MetaPluginV2, self).__init__() LOG.debug(_("Start initializing metaplugin")) self.supported_extension_aliases = ['flavor', 'external-net', 'router', 'ext-gw-mode', @@ -99,8 +100,6 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2, raise exc.Invalid(_('default_l3_flavor %s is not plugin list') % self.default_l3_flavor) - db.configure_db() - self.extension_map = {} if not cfg.CONF.META.extension_map == '': extension_list = [method_set.split(':') diff --git a/neutron/plugins/metaplugin/proxy_neutron_plugin.py b/neutron/plugins/metaplugin/proxy_neutron_plugin.py index e8faa310d..61cc34026 100644 --- a/neutron/plugins/metaplugin/proxy_neutron_plugin.py +++ b/neutron/plugins/metaplugin/proxy_neutron_plugin.py @@ -17,7 +17,6 @@ from oslo.config import cfg -from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import external_net_db from neutron.db import l3_db @@ -35,7 +34,7 @@ class ProxyPluginV2(db_base_plugin_v2.NeutronDbPluginV2, supported_extension_aliases = ["external-net", "router"] def __init__(self, configfile=None): - db.configure_db() + super(ProxyPluginV2, self).__init__() self.neutron = client.Client( username=cfg.CONF.PROXY.admin_user, password=cfg.CONF.PROXY.admin_password, diff --git a/neutron/plugins/midonet/plugin.py b/neutron/plugins/midonet/plugin.py index a10b689c1..984736dcb 100644 --- a/neutron/plugins/midonet/plugin.py +++ b/neutron/plugins/midonet/plugin.py @@ -33,7 +33,6 @@ from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.db import agents_db from neutron.db import agentschedulers_db -from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import dhcp_rpc_base from neutron.db import external_net_db @@ -209,6 +208,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2, __native_bulk_support = False def __init__(self): + super(MidonetPluginV2, self).__init__() # Read config values midonet_conf = cfg.CONF.MIDONET midonet_uri = midonet_conf.midonet_uri @@ -231,7 +231,6 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2, raise MidonetPluginException(msg=msg) self.setup_rpc() - db.configure_db() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_MIDONET, diff --git a/neutron/plugins/ml2/db.py b/neutron/plugins/ml2/db.py index bf911d3d1..0a2d981a5 100644 --- a/neutron/plugins/ml2/db.py +++ b/neutron/plugins/ml2/db.py @@ -28,10 +28,6 @@ from neutron.plugins.ml2 import models LOG = log.getLogger(__name__) -def initialize(): - db_api.configure_db() - - def add_network_segment(session, network_id, segment): with session.begin(subtransactions=True): record = models.NetworkSegment( diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 8ca62d7df..cacec013e 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -98,10 +98,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, return self._aliases def __init__(self): + super(Ml2Plugin, self).__init__() # First load drivers, then initialize DB, then initialize drivers self.type_manager = managers.TypeManager() self.mechanism_manager = managers.MechanismManager() - db.initialize() self.type_manager.initialize() self.mechanism_manager.initialize() # bulk support depends on the underlying drivers diff --git a/neutron/plugins/mlnx/db/mlnx_db_v2.py b/neutron/plugins/mlnx/db/mlnx_db_v2.py index 50dd7057a..23f48e2df 100644 --- a/neutron/plugins/mlnx/db/mlnx_db_v2.py +++ b/neutron/plugins/mlnx/db/mlnx_db_v2.py @@ -29,10 +29,6 @@ from neutron.plugins.mlnx.db import mlnx_models_v2 LOG = logging.getLogger(__name__) -def initialize(): - db.configure_db() - - def _remove_non_allocatable_vlans(session, allocations, physical_network, vlan_ids): if physical_network in allocations: diff --git a/neutron/plugins/mlnx/mlnx_plugin.py b/neutron/plugins/mlnx/mlnx_plugin.py index a8cbe90b9..cee2e4b3d 100644 --- a/neutron/plugins/mlnx/mlnx_plugin.py +++ b/neutron/plugins/mlnx/mlnx_plugin.py @@ -95,7 +95,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2, def __init__(self): """Start Mellanox Neutron Plugin.""" - db.initialize() + super(MellanoxEswitchPlugin, self).__init__() self._parse_network_vlan_ranges() db.sync_network_states(self.network_vlan_ranges) self._set_tenant_network_type() diff --git a/neutron/plugins/nec/db/api.py b/neutron/plugins/nec/db/api.py index e606861ff..b5935f588 100644 --- a/neutron/plugins/nec/db/api.py +++ b/neutron/plugins/nec/db/api.py @@ -56,10 +56,6 @@ def _get_resource_model(resource, old_style): return resource_map[resource] -def initialize(): - db.configure_db() - - def clear_db(base=model_base.BASEV2): db.clear_db(base) diff --git a/neutron/plugins/nec/nec_plugin.py b/neutron/plugins/nec/nec_plugin.py index 41aaf61f7..95e35ffce 100644 --- a/neutron/plugins/nec/nec_plugin.py +++ b/neutron/plugins/nec/nec_plugin.py @@ -102,8 +102,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2, return self._aliases def __init__(self): - - ndb.initialize() + super(NECPluginV2, self).__init__() self.ofc = ofc_manager.OFCManager() self.base_binding_dict = self._get_base_binding_dict() portbindings_base.register_port_dict_function() diff --git a/neutron/plugins/nicira/NeutronPlugin.py b/neutron/plugins/nicira/NeutronPlugin.py index c4ad96bea..6239ca51f 100644 --- a/neutron/plugins/nicira/NeutronPlugin.py +++ b/neutron/plugins/nicira/NeutronPlugin.py @@ -38,7 +38,6 @@ from neutron.common import utils from neutron import context as q_context from neutron.db import agentschedulers_db from neutron.db import allowedaddresspairs_db as addr_pair_db -from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import external_net_db from neutron.db import extraroute_db @@ -144,7 +143,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin, novazone_cluster_map = {} def __init__(self): - + super(NvpPluginV2, self).__init__() # TODO(salv-orlando): Replace These dicts with # collections.defaultdict for better handling of default values # Routines for managing logical ports in NVP @@ -185,7 +184,6 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin, pbin.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} - db.configure_db() self._extend_fault_map() self.setup_dhcpmeta_access() # Set this flag to false as the default gateway has not diff --git a/neutron/plugins/openvswitch/ovs_db_v2.py b/neutron/plugins/openvswitch/ovs_db_v2.py index b28df3e12..821163d80 100644 --- a/neutron/plugins/openvswitch/ovs_db_v2.py +++ b/neutron/plugins/openvswitch/ovs_db_v2.py @@ -33,10 +33,6 @@ from neutron.plugins.openvswitch import ovs_models_v2 LOG = logging.getLogger(__name__) -def initialize(): - db.configure_db() - - def get_network_binding(session, network_id): session = session or db.get_session() try: diff --git a/neutron/plugins/openvswitch/ovs_neutron_plugin.py b/neutron/plugins/openvswitch/ovs_neutron_plugin.py index 450ce3dd2..fde00edeb 100644 --- a/neutron/plugins/openvswitch/ovs_neutron_plugin.py +++ b/neutron/plugins/openvswitch/ovs_neutron_plugin.py @@ -294,12 +294,12 @@ class OVSNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, attributes.NETWORKS, ['_extend_network_dict_provider_ovs']) def __init__(self, configfile=None): + super(OVSNeutronPluginV2, self).__init__() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} - ovs_db_v2.initialize() self._parse_network_vlan_ranges() ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges) self.tenant_network_type = cfg.CONF.OVS.tenant_network_type diff --git a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py index fb389c434..1f8f99c0d 100644 --- a/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py +++ b/neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py @@ -25,7 +25,6 @@ import netaddr from oslo.config import cfg from neutron.api.v2 import attributes -from neutron.db import api as db from neutron.db import db_base_plugin_v2 from neutron.db import external_net_db from neutron.db import l3_db @@ -69,9 +68,7 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2, def __init__(self): LOG.info(_('Neutron PLUMgrid Director: Starting Plugin')) - # Plugin DB initialization - db.configure_db() - + super(NeutronPluginPLUMgridV2, self).__init__() self.plumgrid_init() LOG.debug(_('Neutron PLUMgrid Director: Neutron server with ' diff --git a/neutron/plugins/ryu/ryu_neutron_plugin.py b/neutron/plugins/ryu/ryu_neutron_plugin.py index 5fe2845b1..c81b2069f 100644 --- a/neutron/plugins/ryu/ryu_neutron_plugin.py +++ b/neutron/plugins/ryu/ryu_neutron_plugin.py @@ -109,13 +109,13 @@ class RyuNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, return self._aliases def __init__(self, configfile=None): + super(RyuNeutronPluginV2, self).__init__() self.base_binding_dict = { portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS, portbindings.CAPABILITIES: { portbindings.CAP_PORT_FILTER: 'security-group' in self.supported_extension_aliases}} portbindings_base.register_port_dict_function() - db.configure_db() self.tunnel_key = db_api_v2.TunnelKey( cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max) self.ofp_api_host = cfg.CONF.OVS.openflow_rest_api diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py index 8e4a0b40f..6339c834a 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_db.py @@ -100,7 +100,7 @@ class VlanAllocationsTest(base.BaseTestCase): def setUp(self): super(VlanAllocationsTest, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() n1kv_db_v2.sync_vlan_allocations(self.session, VLAN_RANGES) @@ -284,7 +284,7 @@ class VxlanAllocationsTest(base.BaseTestCase, def setUp(self): super(VxlanAllocationsTest, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() n1kv_db_v2.sync_vxlan_allocations(self.session, VXLAN_RANGES) @@ -392,7 +392,7 @@ class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): def setUp(self): super(NetworkBindingsTest, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() def tearDown(self): @@ -643,7 +643,7 @@ class NetworkProfileTests(base.BaseTestCase, def setUp(self): super(NetworkProfileTests, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() def tearDown(self): @@ -828,7 +828,7 @@ class PolicyProfileTests(base.BaseTestCase): def setUp(self): super(PolicyProfileTests, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() def tearDown(self): @@ -876,7 +876,7 @@ class ProfileBindingTests(base.BaseTestCase, def setUp(self): super(ProfileBindingTests, self).setUp() - n1kv_db_v2.initialize() + db.configure_db() self.session = db.get_session() def tearDown(self): diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py index b698e09d8..6cbbeea25 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py @@ -395,4 +395,4 @@ class TestN1kvNonDbTest(base.BaseTestCase): """ def test_db(self): - n1kv_db_v2.initialize() + db.configure_db() diff --git a/neutron/tests/unit/linuxbridge/test_lb_db.py b/neutron/tests/unit/linuxbridge/test_lb_db.py index 737747c4e..37885f814 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_db.py +++ b/neutron/tests/unit/linuxbridge/test_lb_db.py @@ -38,7 +38,7 @@ PLUGIN_NAME = ('neutron.plugins.linuxbridge.' class NetworkStatesTest(base.BaseTestCase): def setUp(self): super(NetworkStatesTest, self).setUp() - lb_db.initialize() + db.configure_db() lb_db.sync_network_states(VLAN_RANGES) self.session = db.get_session() self.addCleanup(db.clear_db) @@ -154,7 +154,7 @@ class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): cfg.CONF.set_override('network_vlan_ranges', ['physnet1:1000:2999'], group='VLANS') super(NetworkBindingsTest, self).setUp(plugin=PLUGIN_NAME) - lb_db.initialize() + db.configure_db() self.session = db.get_session() def test_add_network_binding(self): diff --git a/neutron/tests/unit/ml2/test_type_gre.py b/neutron/tests/unit/ml2/test_type_gre.py index 4a2b27923..dd52f0dbf 100644 --- a/neutron/tests/unit/ml2/test_type_gre.py +++ b/neutron/tests/unit/ml2/test_type_gre.py @@ -18,7 +18,6 @@ from testtools import matchers from neutron.common import exceptions as exc import neutron.db.api as db -from neutron.plugins.ml2 import db as ml2_db from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_gre from neutron.tests import base @@ -35,7 +34,7 @@ class GreTypeTest(base.BaseTestCase): def setUp(self): super(GreTypeTest, self).setUp() - ml2_db.initialize() + db.configure_db() self.driver = type_gre.GreTypeDriver() self.driver.gre_id_ranges = TUNNEL_RANGES self.driver._sync_gre_allocations() @@ -187,7 +186,7 @@ class GreTypeMultiRangeTest(base.BaseTestCase): def setUp(self): super(GreTypeMultiRangeTest, self).setUp() - ml2_db.initialize() + db.configure_db() self.driver = type_gre.GreTypeDriver() self.driver.gre_id_ranges = self.TUNNEL_MULTI_RANGES self.driver._sync_gre_allocations() diff --git a/neutron/tests/unit/ml2/test_type_vxlan.py b/neutron/tests/unit/ml2/test_type_vxlan.py index e4cd829b3..f7121126c 100644 --- a/neutron/tests/unit/ml2/test_type_vxlan.py +++ b/neutron/tests/unit/ml2/test_type_vxlan.py @@ -21,7 +21,6 @@ from testtools import matchers from neutron.common import exceptions as exc from neutron.db import api as db from neutron.plugins.common import constants as p_const -from neutron.plugins.ml2 import db as ml2_db from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_vxlan from neutron.tests import base @@ -42,7 +41,7 @@ VXLAN_UDP_PORT_TWO = 8888 class VxlanTypeTest(base.BaseTestCase): def setUp(self): super(VxlanTypeTest, self).setUp() - ml2_db.initialize() + db.configure_db() cfg.CONF.set_override('vni_ranges', [TUNNEL_RANGES], group='ml2_type_vxlan') cfg.CONF.set_override('vxlan_group', MULTICAST_GROUP, @@ -207,7 +206,7 @@ class VxlanTypeMultiRangeTest(base.BaseTestCase): def setUp(self): super(VxlanTypeMultiRangeTest, self).setUp() - ml2_db.initialize() + db.configure_db() self.driver = type_vxlan.VxlanTypeDriver() self.driver.vxlan_vni_ranges = self.TUNNEL_MULTI_RANGES self.driver._sync_vxlan_allocations() diff --git a/neutron/tests/unit/mlnx/test_mlnx_db.py b/neutron/tests/unit/mlnx/test_mlnx_db.py index b79b871c4..c02c19e45 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_db.py +++ b/neutron/tests/unit/mlnx/test_mlnx_db.py @@ -35,7 +35,7 @@ TEST_NETWORK_ID = 'abcdefghijklmnopqrstuvwxyz' class SegmentationIdAllocationTest(base.BaseTestCase): def setUp(self): super(SegmentationIdAllocationTest, self).setUp() - mlnx_db.initialize() + db.configure_db() mlnx_db.sync_network_states(VLAN_RANGES) self.session = db.get_session() self.addCleanup(db.clear_db) @@ -158,7 +158,7 @@ class SegmentationIdAllocationTest(base.BaseTestCase): class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): def setUp(self): super(NetworkBindingsTest, self).setUp() - mlnx_db.initialize() + db.configure_db() self.session = db.get_session() def test_add_network_binding(self): diff --git a/neutron/tests/unit/nec/test_ofc_manager.py b/neutron/tests/unit/nec/test_ofc_manager.py index 309a4ac30..0d7a5f701 100644 --- a/neutron/tests/unit/nec/test_ofc_manager.py +++ b/neutron/tests/unit/nec/test_ofc_manager.py @@ -18,6 +18,7 @@ import mock from neutron import context +from neutron.db import api as db from neutron.openstack.common import uuidutils from neutron.plugins.nec.common import config from neutron.plugins.nec.db import api as ndb @@ -44,9 +45,9 @@ class OFCManagerTestBase(base.BaseTestCase): def setUp(self): super(OFCManagerTestBase, self).setUp() + db.configure_db() driver = "neutron.tests.unit.nec.stub_ofc_driver.StubOFCDriver" config.CONF.set_override('driver', driver, 'OFC') - ndb.initialize() self.addCleanup(ndb.clear_db) self.ofc = ofc_manager.OFCManager() # NOTE: enable_autocheck() is a feature of StubOFCDriver diff --git a/neutron/tests/unit/openvswitch/test_ovs_db.py b/neutron/tests/unit/openvswitch/test_ovs_db.py index b53fa4df2..91aefe09d 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_db.py +++ b/neutron/tests/unit/openvswitch/test_ovs_db.py @@ -48,7 +48,7 @@ PLUGIN_NAME = ('neutron.plugins.openvswitch.' class VlanAllocationsTest(base.BaseTestCase): def setUp(self): super(VlanAllocationsTest, self).setUp() - ovs_db_v2.initialize() + db.configure_db() ovs_db_v2.sync_vlan_allocations(VLAN_RANGES) self.session = db.get_session() self.addCleanup(db.clear_db) @@ -192,7 +192,7 @@ class VlanAllocationsTest(base.BaseTestCase): class TunnelAllocationsTest(base.BaseTestCase): def setUp(self): super(TunnelAllocationsTest, self).setUp() - ovs_db_v2.initialize() + db.configure_db() ovs_db_v2.sync_tunnel_allocations(TUNNEL_RANGES) self.session = db.get_session() self.addCleanup(db.clear_db) @@ -302,7 +302,7 @@ class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase): cfg.CONF.set_override('network_vlan_ranges', ['physnet1:1000:2999'], group='OVS') super(NetworkBindingsTest, self).setUp(plugin=PLUGIN_NAME) - ovs_db_v2.initialize() + db.configure_db() self.session = db.get_session() def test_add_network_binding(self): diff --git a/neutron/tests/unit/test_quota_ext.py b/neutron/tests/unit/test_quota_ext.py index 627e257da..7c395c133 100644 --- a/neutron/tests/unit/test_quota_ext.py +++ b/neutron/tests/unit/test_quota_ext.py @@ -29,7 +29,6 @@ from neutron.common import exceptions from neutron import context from neutron.db import api as db from neutron.db import quota_db -from neutron.plugins.linuxbridge.db import l2network_db_v2 from neutron import quota from neutron.tests import base from neutron.tests.unit import test_api_v2 @@ -73,7 +72,7 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase): # extra1 here is added later, so have to do it manually quota.QUOTAS.register_resource_by_name('extra1') ext_mgr = extensions.PluginAwareExtensionManager.get_instance() - l2network_db_v2.initialize() + db.configure_db() app = config.load_paste_app('extensions_test_app') ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) self.api = webtest.TestApp(ext_middleware) -- 2.45.2