remove hardcode of usage

Refine the definition of USAGE in control.py

Change-Id: I0f515565455e867384ae179a8eca8e35cb0ff3ad
Return 204 when image data does not exist

Currently a GET on image-data in glance v2 returns 404 when data does not
exist. But according to the API docs the HTTP status code returned in this
case should be 204.

This fix makes Glance return the right HTTP status code.

Change-Id: I34cf68e96f631f05cff349329245f74aee42397c
Closes-Bug: #1251055
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 "Return 204 when image data does not exist"
Merge "Fixes HTTP 500 when updating image with locations for V2"
Merge "remove hardcode of usage"
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
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"