Adds support for username to match the v2 spec

The v2.0 API spec uses username for the user's name, whereas the v3 API
just uses name. The v2.0 implementaion incorrectly used name instead of
username, but did allow a username to be specified and stored in the
extras.

This patch makes the implementation more closely conform to the API
without breaking backward compatibility. Anyone using name in the v2.0
API can continue to do so. They can even specify a username that will
still get stored in the extras. Users can now use the documented
username instead of name and the API will work for them as well.

Both name and username will always be returned for the v2 API calls.

DocImpact
Change-Id: Ia95aa5d442a8311925399fa59e5022d31f68d374
Closes-Bug: #1214686
Sync several modules from oslo-incubator

This change syncronizes excutils,lockutils,log, and
db.sqlalchemy.session modules from oslo-incubator
commit 19e0a51204df247dc38de880d08e6d66e89e6572 .

 $ python update.py --nodeps --base keystone --dest-dir ../keystone \
     --modules  excutils,lockutils,log,db.sqlalchemy.session

This includes fixes for 2 problems:

"keystone=INFO" was in the default_log_levels. This made it
more difficult than necessary to debug the Keystone server,
since you can set debug=True but then the keystone logging
level is overridden and you get no debug output for keystone.

"keystone=INFO" may have been in the default_log_levels because
of the auth_token middleware, but this has been moved to
python-keystoneclient now and the logging config for the
python APIs is done differently.

Closes-Bug: 1245629

Also, fixes some warnings and errors when docs are generated.

Change-Id: I53868bef975f73b4aee35695b6387b718c4179f9
Clean up docstrings in contrib.oauth1.core

The docstrings were using the wrong parameter name.

Change-Id: I237b2b137fa8c8f6138a4a7eacf6140843517225
Merge db.sqlalchemy from oslo-incubator af5f710

The db.sqlalchemy module was not recent with oslo-incubator.

 $ git checkout af5f71096c7bb83fe2f956588a9ec643b0d9a2f6
 $ python update.py --nodeps --base keystone \
   --dest-dir ../keystone --modules db.sqlalchemy

The af5f710 oslo-incubator db.sqlalchemy contains a fix for the
following problem, which caused a regression in Keystone:

The database connection string was not marked as secret, so it
would be printed out in cleartext in the logs when config settings
were logged.

The database connection string typically contains the password
that's used to connect to the database, so it should be marked as
secret so that it doesn't get logged.

Change-Id: Ibdc63480a836646c5571a368f3c3a1d0c82d6aba
Closes-Bug: #1266590
Subclasses of TestCase don't need to reset conf

Subclasses of TestCase were unnecessarily resetting the config on
cleanup. This is unnecessary because TestCase resets the config
already.

This takes care of some TODOs in the code.

Change-Id: I4350efb03a40616e6a9e7fb6ee7cc507f4709f00
Cleanup test_no_admin_token_auth cleanup code

The addCleanup call for the temporary paste config file was separated
from where it was needed because the function that required it
was outside the TestNoAdminTokenAuth class. This moves the
function to be a member and moves the addCleanup call in the
member function right where it's needed.

It's better to put the addCleanup code close to where it's needed
because then it will be called even if an exception occurs.

Change-Id: I50c97a3229958f4d15c7cd68ffa2a9d45914d1db
Safe command handling for openssl

The openssl command line was passed to exec() as a string with
no attempt at escaping. This could lead to odd results if someone
configured their system with a space in the filename of a key.

The fix is to pass the command to exec() safely, as a list.

Change-Id: I4faa2b66f79bf6ffddabf4a0f0b407ce9afa72d2
Remove unused variables

Remove unused variables in keystone/tests/test_v3_identity.py

Change-Id: Ia70242aa6ceaebfe8380f3de879b5b7885ca80d5
Closes-Bug: #1268094
Fix sample config external default doc

The sample config file documented the incorrect default for the
[auth].external value as defined in keystone.common.config.

Change-Id: I6f9454f35eaade5fa35738a9ba3f74a388bf5099
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
derive custom exceptions directly from Exception

Although StandardError derives from Exception, the python docs for
Exception read:

    All user-defined exceptions should also be derived from this class.

http://docs.python.org/2/library/exceptions.html#exceptions.Exception

Change-Id: If0f009cd0ad5a30329f0f97d869137aeef66af23
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
Enable lazy translation

This change makes it so that if the user makes a request with an
Accept-Language header and the response is an error where the
message is translatable, then the message will be translated to
the requested language (or the most appropriate language
available).

completes bp user-locale-api

Change-Id: I5b0b02e0459a6a444baa12f8722adb829b7e152b
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
Document running with pdb

There was no documentation in "Developing with Keystone" that
makes it obvious that you can use "tox -e debug" to run with pdb
breakpoints.

Change-Id: I82cc827d076a4d95ab6a2f903ceb0cde34005bc3
Reduces memory utilization during test runs

It turns out that when the Python test framework runs it will create an
instance of TestCase (actually the subclass containing our tests) of
each test in the TestCase. These instances don't get cleaned up until
the very end of the test run. This means that if there are lots of tests
and/or lots of instance variables created in the setUp() you use lots of
memory.

Change-Id: Ie9451feafd47d4a4b9a0ff6d8459b45a1645d1ee
Implements regions resource in 3.2 Catalog API

Adds CRUD implementation in SQL and KVS catalog drivers
for hierarchical regions support. The SQL driver implements
the region hierarchy using a simple adjacency list model
since it is expected that typical deployments will only
have a handful of regions, and the current regions API does
not offer any complex hierarchy querying that would make
a nested set model more appropriate.

Implements: blueprint first-class-regions

Change-Id: I2d4cca19008b92ef5758181b1792726834db7f7a
Sync with global requirements

Change-Id: Ibdd73aa142be103d285ce0f15701dc96c1ec34ae
rename templated.TemplatedCatalog to templated.Catalog

This addresses a long standing TODO for consistency across catalog
drivers, making it more intuitive to switch drivers.

UpgradeImpact

Change-Id: I109513695e60867d1111795ab958a3cc4240e831
Enhance tests for non-default default_domain_id

There were no tests that show what happens when the
default_domain_id is changed from the default. The new tests show
that in some cases the behavior is incorrect, and in other cases
it is correct.

Change-Id: Ia167e153f488617f94afce7fddfc52e1e2c8e79c
Related-Bug: #1265108