Catch exception.InUseByStore at API layer

If user create an image with Ceph backend driver, and then create
an instance based on the image. As a result, user will run into
500 error when deleting the image. Because rbd driver is raising
exception.InUseByStore()at [1] when the image is in use, but no
code to catch the exception at REST API layer.

[1] https://github.com/openstack/glance/blob/master/glance/store/rbd.py#L290

Closes-Bug: 1345942

Change-Id: I350c235944aab226dc96de169be2087e2b599ab4
Fix migration on older postgres

Since the move to oslo.db, sqlalchemy no longer raises
ProgrammingError.  Instead, it is wrapped in a
oslo.db.exception.DBError. This causes migration to fail on older
postgres, which relies on catching this error to use the correct
constraint name.

Change-Id: Icf7b20eb4e09f3c91aa3df3bcea497f810a6f907
Bump osprofiler requirement to 0.3.0

ofprofiler.notifier.create, which is used by recently merged
commit 94b670c199fcc39784edd90b323b0396914ce66a, does not seem
available in osprofiler 0.1.1.

Closes-Bug: #1354500
Change-Id: I563558efcf4e909e2a97003bf84a0785091fd360
Ensure constant order when setting all image tags

The newer version of tox (>=1.7.0) sets a random hash seed, which makes the
order of sets unpredictable. This patchset fixes the test_image_tag_set_all
test, which otherwise broke with a randomized PYTHONHASHSEED. This new tox
behaviour is consistent with python (>=3.3), meaning this change should avoid
bugs on that platform at a later date.

Change-Id: Ie281b04fc9c4c2a96a9eec9bde7b05229ebf57fc
Partial-bug: #1348818
Do not assume order of images

This fixes the test_tag_lifecycle test, which broke with a randomized
PYTHONHASHSEED.

Previously, the test assumed that the values in the list of tag names
would remain constant. The test now sorts the results and compares to a
sorted set.

Change-Id: If5a2ef683fcf55520c7d539f1b90aefaba4739d5
Partial-bug: #1348818
Merge "Fix migration on older postgres"
Enforce image_size_cap on v2 upload

image_size_cap should be checked and enforced on upload

Enforcement is in two places:
- on image metadata save
- during image save to backend store

Closes-Bug: 1315321
Change-Id: I45bfb360703617bc394e9e27fe17adf43b09c0e1
Co-Author: Manuel Desbonnet <manuel.desbonnet@hp.com>
Merge "Do not assume order of images"
Merge "Ensure constant order when setting all image tags"
Merge "Enforce image_size_cap on v2 upload"
Log task ID when the task status changes

This patch adds the task ID to the existing log messages which
occur when the task status changes, whether successful or a
failure.

Change-Id: Ie1ebdd92805370b706d8d9eec29d1b433095369a
Closes-Bug: 1358888
Imported Translations from Transifex

Change-Id: If853cd78bb773fc20eced3f507dc0ccb3dbf8797
Merge "Catch exception.InUseByStore at API layer"
Replacement mox by mock

Replace mox testing library by mock one in:
- glance/tests/unit/common/test_rpc.py,
- glance/tests/unit/test_filesystem_store.py,
- glance/tests/unit/v1/test_registry_client.py,
- glance/tests/unit/v1/test_upload_utils.py,
- glance/tests/unit/v2/test_registry_client.py

Partially Implements: blueprint replace-mox-with-mock

Change-Id: Idbdec5a23d88cee22e9045d43739bfa09b6b4523
Merge "Bump osprofiler requirement to 0.3.0"
Merge "Imported Translations from Transifex"
Check on schemes not stores

Since the `_upload` method loads the store based on the scheme, we need
to check whether the scheme exists in the known schemes instead of
checking in the list of known stores. Without this fix, stores with a
scheme name different than the store itself will not be usable through
the `x-image-meta-store` header.

Change-Id: Ia33afc1629cb47a31982df7932ac0d9aeb201b4f
Closes-bug: #1357462
Merge "Check on schemes not stores"
Merge "Replacement mox by mock"