diff --git a/neutron/db/api.py b/neutron/db/api.py index aec9aad7f47..10124515da0 100644 --- a/neutron/db/api.py +++ b/neutron/db/api.py @@ -16,6 +16,7 @@ import contextlib from debtcollector import moves +from debtcollector import removals from oslo_config import cfg from oslo_db import api as oslo_db_api from oslo_db import exception as db_exc @@ -115,8 +116,7 @@ def exc_to_retry(exceptions): raise db_exc.RetryRequest(e) -#TODO(akamyshnikova): when all places in the code, which use sessions/ -# connections will be updated, this won't be needed +@removals.remove(version='Newton', removal_version='Ocata') def get_engine(): """Helper method to grab engine.""" return context_manager.get_legacy_facade().get_engine() diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 96a357e6a44..a0e331e2047 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -6427,7 +6427,7 @@ class DbOperationBoundMixin(object): def _event_incrementer(*args, **kwargs): self._db_execute_count += 1 - engine = db_api.get_engine() + engine = db_api.context_manager.get_legacy_facade().get_engine() event.listen(engine, 'after_execute', _event_incrementer) self.addCleanup(event.remove, engine, 'after_execute', _event_incrementer) diff --git a/neutron/tests/unit/extensions/test_flavors.py b/neutron/tests/unit/extensions/test_flavors.py index e37aa8c41a6..55095e14b87 100644 --- a/neutron/tests/unit/extensions/test_flavors.py +++ b/neutron/tests/unit/extensions/test_flavors.py @@ -461,7 +461,7 @@ class FlavorPluginTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase, self.service_manager.add_provider_configuration( provider.split(':')[0], provconf.ProviderConfiguration()) - dbapi.get_engine() + dbapi.context_manager.get_legacy_facade().get_engine() def _create_flavor(self, description=None): flavor = {'flavor': {'name': 'GOLD', diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index f833cbd618d..c881eb8051d 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -1072,7 +1072,7 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase): raise db_exc.DBDuplicateEntry() listener = IPAllocationsGrenade() - engine = db_api.get_engine() + engine = db_api.context_manager.get_legacy_facade().get_engine() event.listen(engine, 'before_cursor_execute', listener.execute) event.listen(engine, 'commit', listener.commit) self.addCleanup(event.remove, engine, 'before_cursor_execute', diff --git a/neutron/tests/unit/test_wsgi.py b/neutron/tests/unit/test_wsgi.py index a824b729a4f..a8cfedd5b8e 100644 --- a/neutron/tests/unit/test_wsgi.py +++ b/neutron/tests/unit/test_wsgi.py @@ -26,7 +26,6 @@ import webob import webob.exc from neutron.common import exceptions as n_exc -from neutron.db import api from neutron.tests import base from neutron.tests.common import helpers from neutron import wsgi @@ -67,10 +66,8 @@ class TestServiceBase(base.BaseTestCase): class TestWorkerService(TestServiceBase): """WorkerService tests.""" - @mock.patch('neutron.db.api.get_engine') + @mock.patch('neutron.db.api.context_manager.get_legacy_facade') def test_start_withoutdb_call(self, apimock): - # clear engine from other tests - api._FACADE = None _service = mock.Mock() _service.pool.spawn.return_value = None