Handle 300 status code in common HTTPClient

Common HTTPClient uses requests library for http communication, but
this library raise no exception if we get code 300 as response status.
On the other hand, some openstack clients (ceilometerclient,
glanceclient, heatclient, ironiccilent, tuskarclient) handles this
status code and raise a special exception in such case. So we should
provide a special exception for 300 status code in common apiclient.

Added required exception - MultipleChoices.

blueprint common-client-library-2

Change-Id: I991737dd4c2d8bdf8bbb5380f05d4cf2b3bcf953
Add remove external lock files API in lockutils

when external lock are used, there will be a lock files which
is used for external file lock, it will not be removed and remain
forever. it will be a problem when tens of thousands of this kind
of actions. Add a API to allow other component to remove lock file
internal lock will be acquired before further action

Change-Id: I4d996b91bcc55becb0ebf4ec77ac80546f433ae9
Closes-Bug: 1256306
Add test for raising errors in HTTPClient

Class `HTTPClient` doesn't have tests for raising errors.
This patch tests HTTPClient:
* when server returned status code #400 (Bad Request);
* when auth plugin does not return any token and endpoint.
* when client_request raises Unauthorized

Change-Id: Ic30db9fade2368c51db742d3809e84885b8e41b3
update.py fails silently if module is not found

update.py can be used to copy individual modules into OpenStack components by
using the --modules switch and providing a module name. However, if this module
is not found is oslo, the user is not informed that the copy failed. Print a
message in this case, and provide the path to the file that the script tried
to copy.

Change-Id: I6f811cd9a412d83a4d83f29c8f8398ca0503f7f4
Closes-Bug: #1274647
Fix requirements file ordering

Since this was fixed the first time, a new change was merged that
broke the alphabetical ordering of the file.  This will cause
problems with the change to enforce that ordering.

Change-Id: I66407706dec8237def6ffa2ea29b56d2db4a241f
Normalize Scheduler Weights

Currently we are using the raw values directly from the available
weighers instead of normalizing them. This makes difficult to
properly use multipliers for establishing the relative importance
between two weighters (one big magnitude will shade a smaller one).

Changes introduced in this commit:
1) It introduces weight normalization so that we can apply multipliers
easily. All the weights for an object will be normalized between 0.0
and 1.0 before being sumed up, so that the final weight for a host
will be:

weight = w1_multiplier * norm(w1) + w2_multiplier * norm(w2) + ...

2) base_weight.BaseWeigher has been changed into an ABC so that we
enforce that all weighers have the expected methods.

3) base_weight.BaseWeigher.weigh_objects() does no longer sum up the
computer weighs to the object, but it rather returns a list that will
be then normalized and added to the existing weight by BaseWeightHandler.

4) Change _weight_multiplier() to weight_multiplier() as a public method

Port from I81bf90898d3cb81541f4390596823cc00106eb20
Related to bp nova-oslo-scheduler

Change-Id: I1b0c7a6e141eee699a191f8a59db90d063eb31ba
Implements part of bp normalize-scheduler-weights
Fix DictOpt support in config sample generator

Class DictOpt was defined in oslo.config.cfg .
The config sample generator cannot recognize DictOpt type config options,
and will exit with exception when generating config sample files from codes
that contain DictOpt type options. This will result in unexpected output
of tools/config/generate_sample.sh and tools/config/check_uptodate.sh.
This problem is fixed by adding DictOpt support to config sample generator.

Change-Id: Ia360dbfae8446ddaa563e94f51900071e95cdf6d
Closes: bug #1276859
Emit message which merged user-supplied argument in log_handler

When using PublishErrorsHandler, it will missing user-supplied arguments.
For example, do LOG.info("blabla %s", "foo"), the payload only contains
"blabla %s", but we expect it like "blabla foo". This patch fix it.

Change-Id: I91289cc4a60f5dab89bca852e6f52b4b83831e47
Closes-bug: #1278291
Fix tools/graduate.sh for work with directories

graduate.sh script works fine with files, but if we try create
new oslo library from existing directory, we get an
incorrect file structure.

For example if we run

 tools/graduate.sh foo openstack/common/foo/ tests/unit/test_foo/

We'll get file structure like

 oslo/foo/foo/file1.py

Added to graduate.sh `is directory` check to fix this issue.

Change-Id: Idd73288b12db54a44de14dbdef44fd8fd6617373
Rename Openstack to OpenStack

Change-Id: Id7d41fa8ec29e4f8f4b3df5ddf6c4b4028867ef2
Update oslo log messages with translation domains

Update the incubator code to use different domains for log
messages at different levels.

Update the import exceptions setting for hacking to allow
multiple functions to be imported from gettextutils on one
line.

bp log-messages-translation-domain

Change-Id: I6ce0f4a59438612ce74c46b3ee9398bef24c0c19
Update cookiecutter git URL

The oslo-cookiecutter repo has been imported into our git server,
so update the URL to point there instead of github.

bp graduation-tool

Change-Id: Iff8dd50e68b138304622f64e9af5320d9fb0ab1a
Removes use of timeutils.set_time_override

The set_time_override function in timeutils was written as a
helper function to mock utcnow for unittests before 'mock' was
generally used. Now that we have mock and fixture, we no longer
need to use it.

Change-Id: If6532efe7f3edc91ca3394793a5cc6d4b9435655
Skip __pycache__ in maintainers check

When tox runs, tools/check_maintainers.py fails with an error
``Directory __pycache__ not found in MAINTAINERS``

This happens, because unittest on py33 was merged to master, and
python 3 stores bytecode in the __pycache__ folder. So we should
not check an entry for this folder in MAINTAINERS file.

Change-Id: I3f311f37262739e50a59164e204d8ff806f5f408
Documenting policy.json syntax

Adding some documentation about policy.json usage.

Change-Id: I4df6d470432d9d8cef8cf63d5cce8a995ef79516
Fix duplicating of SQL queries in logs

Remove setting and passing echo parameter to create_engine()
function and replace it with configuring log level directly on
logger sqlalchemy.engine (this prevents adding of multiple
handlers writing to stderr to the root logger).

Change-Id: I799341a347cfcacdd27c70b91ed9b9e3cc70727f
Closes-Bug: #1278860
Update wiki link in update.py

The old link doesn't exist anymore.

Change-Id: I88ef902c801d16330e535d065fe785724d4c3ba8
Copy the __init__.py from openstack.common

Code has been added in the __init__.py now in the root
directory, so update.py needs to sync this file as well
earlier this file was empty, so we just used to ensure
that the file was created.

Change-Id: Ic9ebc43bce7a5a1ef414957b53055588dfc4d188
Use six.StringIO/BytesIO instead of StringIO.StringIO

to keep Python 3.x compatibility, use six.StringIO/BytesIO to
replace StringIO.StringIO

StringIO works for unicode
BytesIO works for bytes

Change-Id: Id7f4c3f701275229714f45296eac9f7f34ff6ece
Partial-Bug: #1280100
Remove None for dict.get()

Because If no default value is specified it defaults to None already.

Change-Id: Iebbb0622f7941c6ce8ea26aca1968f1ae68a6c14