make record_metering_data concurrency safe

Recording metering might happen in parallel, and if two sqlalchemy
session try to create a source, a user, a project or a resource at the
same time, one of them fail with a IntegrityError.

This patch ensure the record_metering_data sqlalchemy session always
have the needed source, user, project and a resource by creating missing
obj in an other sqlalchemy session.

Fixes bug: #1237671

Change-Id: Ie8761ce1615c3142ad6ad2a400537f465f3bbf0a
Refactor API error handling

Refactor the API error handling to ensure error messages are translated.
Since wsme 0.5b6, the error message doesn't need to be converted to
unicode, wsme handles it for us.

Related bug #1200518

Change-Id: Iec396f045cd3afe817301f0d00917c42c7587b55
Replace mox with mock in tests.api.v2

Change-Id: Id928855178d5bb69d6fc4edf159c4f5cdf633c4e
Updated from global requirements

Change-Id: I9648286d526f4d0d54e6d15e9ed9a0cf36c1f173
Replace mox with mock in energy and objectstore

Replace mox with mock in:

* tests.energy.test_kwapi
* tests.objectstore.test_swift
* tests.objectstore.test_swift_middleware

Change-Id: If1168c6a4884f4a01f33587a14e60ccb3819dbd1
Document user-defined metadata for swift samples

Add a brief documentation on how to configure and use
user-defined metadata for swift samples based on
'metadata_headers' property in swift middleware.

Change-Id: I365db3fda74a6e6ef0e8bcfbad917bcdac8e02ee
Replace mox with mock in tests.storage

Change-Id: I912c999567eba012eb1777f937d1a5785a720d54
Merge "Replace mox with mock in tests.storage"
Fixes Hyper-V Inspector cpu metrics bug

Closes-Bug: 1249959

Change-Id: I39513648ab25d46b2639b24a94e7344954ce3aeb
Merge "Replace mox with mock in energy and objectstore"
Support building wheels (PEP-427)

With that, building and uploading wheels to PyPI is only one "python
setup.py bdist_wheel" away.

Change-Id: I38707119c9b1f1ec43c6a63bde742475fb72279b
Remove useless defined Exception in tests

Change-Id: If02e325074f0bae85eb2671a92f2c2396ed9354d
Replace mox with mock in novaclient and compute

Replace mox with mock in tests.test_novaclient and tests.compute.test_manager.

Change-Id: Ic01fe3fd7510312e1930e87306ccc352d443fb35
Replace mox with mock in publisher and pipeline

Replace mox with mock in tests.publisher and tests.test_pipeline

Change-Id: I3ec2d16bb586c4265cb65414a9b5647832d903f2
Replace mox with mock in tests.collector

Change-Id: I4d8f8ec812a136f9e117535c98c4cbaa29791817
Update hacking for real

Change-Id: Ifa8af9a426c831b26e79b727b01de76b07c50b21
Stop ignoring H506 errors

Change-Id: Ib45d642e8a892c96d8fdf76ca966ddd4d9b0af75
Replace mox with mock in alarm,central,image tests

Replace mox with mock in:

* tests.alarm.test_rpc
* tests.central.test_manager
* tests.image.test_glance

Change-Id: Icb71ccc09c26344c9814ff1f7c958101edd636e7
full pep8 compliance (part1)

first stage of moving to full pep8 compliance

Change-Id: I4626a0949da5b9c49776d1e16cb9ebb49b4e6723
Imported Translations from Transifex

Change-Id: Ieeb3084892f6cfe3bdbf3b24068cb93b5d14ea80