Replace usage of get_legacy_facade() with get_engine()

We've been seeing warnings emitted to the python 3 unit tests:

  OsloDBDeprecationWarning: EngineFacade is deprecated; please use
  oslo_db.sqlalchemy.enginefacade

which stem from our use of the get_legacy_facade() oslo.db method.

This replaces the get_legacy_facade() usage with the get_engine()
method from the transaction context manager.

The same has been done for Nova:
https://review.openstack.org/#/c/606213

Change-Id: I83394d79280c3e22469551f17356d057a26230c4
This commit is contained in:
Vu Cong Tuan 2018-11-06 14:35:02 +07:00
parent b40cb8e0e0
commit 93d012bd0f
1 changed files with 3 additions and 1 deletions

View File

@ -62,7 +62,9 @@ def get_engine(use_slave=False, connection=None):
:param connection: The database connection string
"""
ctxt_mgr = create_context_manager(connection=connection)
return ctxt_mgr.get_legacy_facade().get_engine(use_slave=use_slave)
if use_slave:
return ctxt_mgr.reader.get_engine()
return ctxt_mgr.writer.get_engine()
class SQLRepository(object):