Generalize DB conf group copying

The direct access of conf.* names in _get_db_conf() method
is an inappropriate usage of oslo.config [1].   Hardcoding
these names prevents oslo.db from being able to easily
rename or deprecate options, as well as to be able to
add new database options, such as those which apply
to new performance tuning or monitoring techniques.
Retrieve values from the config object generically so
that these names remain local to oslo.db. This usage has
been supported in oslo.db enginefacade from its inception [2]
as multiple projects were already doing it for LegacyEngineFacade.

This patch is a copy of below nova change:
I22f8a19009408fb1f1587bf399e6aee3467c8bc6

[1] http://lists.openstack.org/pipermail/openstack-dev/2017-July/119846.html
[2] https://github.com/openstack/oslo.db/blob/master/oslo_db/tests/sqlalchemy/test_enginefacade.py#L2140

Change-Id: Ie1f4a8e02ff64be2125443ddcd9b95e4f42f593d
This commit is contained in:
dineshbhor 2018-05-17 22:53:15 -07:00
parent 24e500cb77
commit b50dc8c3d5
1 changed files with 4 additions and 16 deletions

View File

@ -44,22 +44,10 @@ main_context_manager = enginefacade.transaction_context()
def _get_db_conf(conf_group, connection=None):
return {'connection': connection or conf_group.connection,
'slave_connection': conf_group.slave_connection,
'sqlite_fk': False,
'__autocommit': True,
'expire_on_commit': False,
'mysql_sql_mode': conf_group.mysql_sql_mode,
'idle_timeout': conf_group.idle_timeout,
'connection_debug': conf_group.connection_debug,
'max_pool_size': conf_group.max_pool_size,
'max_overflow': conf_group.max_overflow,
'pool_timeout': conf_group.pool_timeout,
'sqlite_synchronous': conf_group.sqlite_synchronous,
'connection_trace': conf_group.connection_trace,
'max_retries': conf_group.max_retries,
'retry_interval': conf_group.retry_interval}
kw = dict(conf_group.items())
if connection is not None:
kw['connection'] = connection
return kw
def _context_manager_from_context(context):