Synchronized with oslo db and db.sqlalchemy

In most cases Oslo-incubator contains the most relevant code.
Furthermore in certain cases exists bugs which can be fixed by
synchronization with Oslo. Thus regular sync is required.

                        Changes from oslo-incubator
==============================================================================
8b2b0b7 Use hacking import_exceptions for gettextutils._
9bc593e Add docstring for exception handlers of session
855644a Removal of _REPOSITORY global variable.
ea6caf9 Remove string.lowercase usage
a33989e Remove eventlet tpool from common db.api
e40903b Database hook enabling traditional mode at MySQL
f2115a0 Replace xrange in for loop with range
c802fa6 SQLAlchemy error patterns improved
1c1f199 Remove unused import
6d0a6c3 Correct invalid docstrings
fb0e86a Use six.moves.configparser instead of ConfigParser
6603e8f Remove sqlalchemy-migrate 0.7.3 patching
97d8cf4 Remove lazy loading of database backend
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Synced from Oslo-Incubator commit: 517c4cc65969f93b4b758a568725a1625abfd24d

Change-Id: Ida6b38b8e41c73c67170e4ec43943e661f014629
Remove unnecessary line in test_auth

TestCase sets up the kvs identity backend already, by using
test_overrides.conf, so this line doesn't do anything and is going
to lead to confusion if test_overrides.conf changes to a different
backend.

Change-Id: I3f62e70a0dd7a27b675a29a56bfbccffa1b9be50
Flush tokens in batches with DB2

When there is a very large number of expired tokens to be flushed,
keystone-manage token_flush will fail with DB2 because it fills
the transaction log. This fix causes tokens to be flushed with DB2 in
batches of 100 at a time to prevent the transaction log from
filling up.

Closes-Bug: #1257323
Change-Id: Ic57d8795a995462fc277ec9655eca9b460ffcbee
Don't need session.flush in context managed by session

Within the scope of a single method, keeping all the reads and writes within
the context managed by a single session. In this way, the session's __exit__
handler will take care of calling flush() and commit() for you.
If using this approach, you should not explicitly call flush() or commit().
See http://docs.sqlalchemy.org/en/rel_0_7/orm/session.html#committing

Closes-Bug: #1258044
Change-Id: I1125c72712203f1594ef245761dbfc25ed31eab2
Sync oslo-incubator rpc	module

Sync oslo-incubator rpc module with oslo-incubator commit
f8f6fd46b3b9264c21c0ee5547a4e8236cb257ac

Updates consist in using six.iteritem and fixing some typos.

Remove securemessage.py, which in not used anywhere, and dropped from
oslo-incubator since commit f88d59ab8a456e7d2d5a22fc5591491d2f85bdf4

$ python update.py --nodeps --base keystone --dest-dir ../keystone/ --modules rpc
$ git rm keystone/openstack/common/rpc/securemessage.py

Change-Id: I890cf1ce89ce5946522f7891be71a3e58ecc1af3
Cleanup test_associate_project_endpoint_extension

This moves the addCleanup closer to where it's required and
takes care of a TODO. Turns out that cleanup up self.conf_files
is required.

Change-Id: I4229b950fe3dc7e575f921f2b63c4462ed459108
Make common log import consistent

Across the project, make the common log import consistent.

Change-Id: I937cd5d337db5d2296dd9238685803bbba3391b3
Merge "Remove unnecessary line in test_auth"
Documentation cleanup

Several warnings and errors were reported when building
documentation. This makes it difficult for developers to
validate that new changes to don't have problems.

Most of the warnings and errors are fixed with this change.

Change-Id: Ifb9edffce66dde27fbe72bb1ce1b997b041786ae
Merge "Make common log import consistent"
Merge "Cleanup test_associate_project_endpoint_extension"
Merge "Synchronized with oslo db and db.sqlalchemy"
Merge "Sync oslo-incubator rpc	module"
Merge "Don't need session.flush in context managed by session"
Merge "Flush tokens in batches with DB2"
Convert Token KVS backend to new KeyValueStore Impl

This patchset converts the current token KVS backend to the new
dogpile.cache based KeyValueStore implementation.  The changeset
provides the same public interface as the previous KVS driver but
drastically reworks the internal mechanisms to be more similar to
the memcache based driver so that direct access to the in-mem db
is not required to effectively use the KeyValueStore.

KVS token backend is not deprecated anymore. However, it is still
inadvisable to use the basic-inmemory KVS backend for anything
outside of testing.

DocImpact

bp: dogpile-kvs-backends
Change-Id: Ib278636d4ffa3f7152287a48d02be598c50f698a
Merge "Documentation cleanup"
Do not append to messages with +

Some code was appending to translated messages using +, which
oslo-incubator's new gettextutils doesn't support.

The code was changed to use a substitution value in the message
instead.

Part of bp user-locale-api

Change-Id: If2bc1821d0057c4cd53ead7eac1712284464b9bf
Sync gettextutils from oslo-incubator 997ab277

Keystone's gettextutils package was behind oslo-incubator's
version. This syncronizes gettextutils from oslo-incubator commit
997ab277 .

bp user-locale-api

Change-Id: If9cf0c83df6d6c8db844a30c605f60e907abcbdd
Restructure developing.rst

The "Developing with Keystone" file was incorrectly structured.

1) The "Building the Documentation" section was under the
"dogpile.cache based Key-Value-Store (KVS)" section, which it's
got nothing to do with.

2) The "Running Tests" section was under the "Initial Sample Data"
section, which it's got nothing to do with.

3) Several testing-related sections could be put under their own
"Testing" section to keep them together.

Change-Id: Icb0c63385d9ccc24b91d17e057e60346ce1a648e