]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add use_slave DB api support
authorAndy Hill <hillad@gmail.com>
Mon, 20 Apr 2015 17:00:28 +0000 (13:00 -0400)
committerAndy Hill <hillad@gmail.com>
Wed, 22 Apr 2015 12:58:02 +0000 (08:58 -0400)
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

neutron/db/api.py

index 4418bbc28258e1541bfd59bcd25f310531a95d26..3a2752ae1bcc292bdb896f08e080adfad89ef549 100644 (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