Fix doc build errors in db.sqlalchemy

There was some invalid rst in the db.sqlalchemy docstrings which
causes warnings to be generated during the doc build and also
causes the docs to be rendered incorrectly.

Change-Id: I5c14b714b3ab0186150e8f3e481bac4c0bb58c25
Drop special case for MySQL traditional mode, update unit tests

Since there are no users of the special-case TRADITIONAL mode set,
it's OK to drop those references and use only the more flexible
one tuned via a config option.

Update the TRADITIONAL mode unit test, and also add one for
STRICT_ALL_TABLES mode.

Change-Id: Ie9df3aaa5f48d992b61a9ea480d1e17519f16422
strutils: Allow safe_{encode,decode} to take bytes as input

In Python 3, passing "b'foo'" to safe_{encode,decode} currently fails. This
patch fixes this issue.

Change-Id: I01a5312700be80f353725fdf13de6413c4eb86f3
Prevent incorrect usage of _wrap_db_error()

_wrap_db_error() has an implicit contract that it can be applied only
to methods of SQLAlchemy Session subclasses. This seems to be a good
task for an assert statement (as it's something we want to check
during development and debugging, but not something that an end user
can trigger, which would require a general runtime check).

Change-Id: I0a15bf4a90b0aea5fa715027d13d8af816f9e72d
Apply testscenarios to imageutils test scripts

There are some corner cases that need to be tested such as
processing floating values in imageutils.QemuImgInfo.
Rather than copy and pasting test scripts, it would be better
to have testscenarios applied for ease of addiing test cases.

The original test case was not removed to prove the new test script
covers the original tests.
The test_imageutils module was removed from py33 tests due to
testscenarios incompatibility.

Change-Id: I4aa71034a5f1e83724efb49ceec3054726e87233
Enable decimal value input in imageutils.QemuImgInfo

Nova has test cases where it image sizes are in float value.
However imageutils has errors when given float values.
This patch enhances the regex to handle float values.
Test cases were added accordingly.

Change-Id: Ifcaf60f5c54d74e8fc317be6808363bce7429cc8
Get mysql_sql_mode parameter from config

Patch Ia527e850671ab9542db5864617384cee21e91bf6 added mysql_sql_mode
option to config, so we should get it's value from CONF object, not
from function argument.

Closes-Bug: #1288445

Change-Id: I4be81718399393d817185abe36f4cc4d3da15000
Merge "Prevent incorrect usage of _wrap_db_error()"
Merge "strutils: Allow safe_{encode,decode} to take bytes as input"
Remove requirements.txt from .gitignore

There is no reason to keep requirements.txt ignored by get, so we should
remove it from .gitignore

Change-Id: I30852f8281d608c5f7c48217c21c3099b9b0fd0e
Merge "Drop special case for MySQL traditional mode, update unit tests"
Merge "Get mysql_sql_mode parameter from config"
Make db utils importable without migrate

One of functions defined in openstack.common.db.sqlalchemy.utils uses
UniqueConstraint class imported from migrate (sqlalchemy-migrate). It
actually makes sense to move import of migrate directly into the
function to make utils module importable in projects which use
alembic instead of sqlalchemy-migrate (e.g. neutron and ironic).

Change-Id: I382f8c14c69050c8f2ea0a0ba6bf2f1eef84e14d
Adapt DB provisioning code for CI requirements

With recent changes made to our CI MySQL openstack_citest user now
has enough priviliges to create and drop databases. But the code,
that we use for provisioning of databases must be updated, so that
it's not mandatory for openstack_citest user to be also able to
do GRANT/ALTER ROLE queries. Actually this simplifies provisioning
code a bit and allows to reuse the same queries for PostgreSQL and
MySQL.

This will be used for opportunistic db test cases as well as for
running of DbTestCase tests on different backends.

Change-Id: Ia917f647182d908dbb2a86659ad8b4e49c492881
Change lazy translation to retain complete dict

When replacement text was retained for later translation, only
the entries that were associated with the keywords in the
format string were retained.  There was a bug in how the keywords
were parsed.  This reduction was done to support the use of
locals() to specify the replacement text.  This is now prevented
by H501 (confirmed in all projects).

This means that instead of fixing the parsing code to correctly
find the keywords, the entire dictionary can now be retained
and the code for finding the keywords and stripping out unused
entries removed.

Change-Id: I7969dc20841d839f68b2ddb29ac47340c6b615e8
Closes-Bug: #1288049
Merge "Fix doc build errors in db.sqlalchemy"
Merge "Make db utils importable without migrate"
Merge "Remove requirements.txt from .gitignore"
User a more accurate max_delay for reconnects

In an HA deployment, a 60 seconds delay between reconnects can be quite
problematic. This patch changes the delay calculation by setting the max
delay to 5s and by changing the way it is increased.

Unfortunately, this is one of the places where both our main drivers are
not consistent. Rabbit's driver uses configuration parameters for this
whereas qpid's driver has never had one. However, I would prefer not
adding configuration paremeters to qpid's driver for the following
reasons:

    1. Most of OpenStack services depend on the messaging layer, hence
    they need it to be available. A 5s delay seems to be reasonable and
    I could argue the need of tune it further. Although so frequent
    reconnects can add load to the network, that wouldn't be the main
    issue if one of the brokers go down.
    2. We're trying to move away from configuration options towards using
    transport URL. This path is still not clear and I would
    prefer avoiding adding new options until we clear it out.

Closes-bug: #1281148
Change-Id: I537015f452eb770acba41fdedfe221628f52a920
Add copyright text to openstack/common/__init__.py

The copyright text was remove from the file and as it now contains
code, it is missing. This patch readds the copyright text and also
fixes formatting, as adds empty lines between the import and the first
line of code.

Closes-bug: #1288877

Change-Id: I37013194cc808d919ff2345099cd1d053ffe7d88