Added unit tests for api/middleware/cache_manage.py

blueprint glance-cache+unittests
Change-Id: I4382bb37795d42f43e3ddf9f95f13bb76400e1bb
remove hardcode of usage

Refine the definition of USAGE in control.py

Change-Id: I0f515565455e867384ae179a8eca8e35cb0ff3ad
Adding missing copy_from policy from policy.json

The current policy.json file is missing the copy_from policy in order
to be exhaustive.

DocImpact
Change-Id: Ibc0d1fa7626629c28c514514a985a6b89db2ac69
Closes-bug: #1258999
Merge duplicate function test_update_add_property()

test_update_add_property was defined twice, overriding
the previous definition. Merge the two implementations

Change-Id: Iaa52ec16f9c4d88040b72f6cda031cacd94a3756
Rename duplicate test_add_copy_from_upload_image_unauthorized

Rename 2nd implementation of
test_add_copy_from_upload_image_unauthorized to
test_add_copy_from_upload_image_unauthorized_with_body, as it
also passes a body as part of the test.

Change-Id: If080f51bfbc3f51257977bcffa01b07d7f06e45b
Increase test coverage for glance.common.wsgi

Add unit tests for wsgi.get_socket.

Change-Id: I3850dca6f6e4dbeca0465c8d751458e255e0fed8
Fixes HTTP 500 when updating image with locations for V2

Based on current implement, user will run into 500 error during
updating locations for a queued image. The root cause is we're
trying to calculate the overall size with current image size and
the number of locations. This fix will get the correct image size
from backend store if current image size is not available.

Fixes bug 1257507

Change-Id: Ia4ac73e36211d475752ee9f4995fc3768fb2981a
Merge "Fixes HTTP 500 when updating image with locations for V2"
Merge "remove hardcode of usage"
Adds guard against upload contention

Protect against concurrent image uploads by allowing the
initial request to proceed and succeed and subsequent
concurrent requests to fail.

We now allow the upload activation to specify what state
it expects to transition to 'active' from. If by the time
the db is updated the transition has already occured i.e.
another upload has succeeded, the upload will fail and data
will be cleaned up.

Fixes: bug 1241025
Change-Id: Ie532b61484bec660910fb9a37429397bde8ef11f
Refine output of glance service managment

Make the output message easier to be understood, and keep
consistent with the normal output of /etc/init.d/XXX XXX

Change-Id: I9f63d4138282b9a4833e3ce02ffd8ce97bd2decc
Add db2 communication error code when check the db connection

Closes-Bug: #1244092

The oslo patch set is 3acd57c2825a8bf6660c3124f12794414622eb26

Change-Id: Ic5244cab4e517f740b398138d4da877affe46ab3
Filter out deleted images from storage usage

All database API's currently include deleted images in the calc of
storage usage. This is not an issue when deleted images don't have
locations. However, there are cases where a deleted image has deleted
locations as well and that causes the current algorithm to count those
locations as if they were allocating space.

Besides this bug, it makes sense to not load deleted / killed /
pending_delete images from the database if we're actually not
considering them as valid images.

The patch also filters out deleted locations.

NOTE: In the case of locations, it was not possible to add a test for
the deleted locations because it requires some changes that are not
worth in this patch. In order to mark a location as deleted, it's
necessary to go through the API and use a PATCH operation. Since this is
a database test, it doesn't make much sense to add API calls to it.
Calling the image_destroy function with an empty location list will
remove all the locations which won't help testing that specific case.

I'll work on a better solution for that in a follow-up patch.

DocImpact

Change-Id: I82f08a8f522c81541e4f77597c2ba0aeb68556ce
Closes-Bug: #1261738
Merge "Filter out deleted images from storage usage"
Merge "Refine output of glance service managment"
Cleanup: remove unused code from store_utils

store_utils.py contains several methods not used anywhere in the
codebase.
This patch removes the unused code.

Change-Id: I8faa87e1dcce053b19a37c19856eb53529e0ec78
Closes-Bug: #1262051
Make Glance code base H201 compliant

Add Exception to all except without any specific exception
class so the code can be H201 compliant

Change-Id: Ibd09e69f70c76837c72023ae87cbbe75c5eb1276
Merge "Merge duplicate function test_update_add_property()"
Make Glance code base H102 compliant

Add the Apache headers where it was missing so the Glance
code base can be H102 compliant

Change-Id: If19841d1752f7ec364098333429ce090374e79cd
Closes-bug: #1263537
Merge "Rename duplicate test_add_copy_from_upload_image_unauthorized"