Add use_slave DB api support

The example configuration refers to slave_connection[1] but slaves aren't used
in the codebase. This change will enable plugin authors to use
slave_connection by passing use_slave=True to the SQLAlchemy session[2][3].

[1] http://docs.openstack.org/juno/config-reference/content/section_neutron.conf.html
[2] http://docs.openstack.org/developer/oslo.db/api/sqlalchemy/session.html#oslo_db.sqlalchemy.session.EngineFacade.get_session
[3] https://wiki.openstack.org/wiki/Slave_usage

Change-Id: I6f46c11fad5c58577654a4011cf82d19f6d3e1e3
This commit is contained in:
Andy Hill 2015-04-20 13:00:28 -04:00
parent ed209643f1
commit d506b50bad

View File

@ -46,11 +46,12 @@ def dispose():
get_engine().pool.dispose()
def get_session(autocommit=True, expire_on_commit=False):
def get_session(autocommit=True, expire_on_commit=False, use_slave=False):
"""Helper method to grab session."""
facade = _create_facade_lazily()
return facade.get_session(autocommit=autocommit,
expire_on_commit=expire_on_commit)
expire_on_commit=expire_on_commit,
use_slave=use_slave)
@contextlib.contextmanager