Improved coverage for glance.api.*

Added new tests for glance.api.v2.image_data,
glance.api.v2.image_members, glance.api.v2.images,
glance.api.v2.schemas, glance.api.v2.image_tags,
glance.api.cached_images.

Part of blueprint improve-api-unit-tests

Change-Id: I2bd39e12366dd1b185bf60a8cd1d03a162ba5896
Changes HTTP response code for unsupported methods

Requests for resources with an unsupported HTTP method now return a HTTP
response 405 (Method Not Allowed) or 501 (Not Implemented) rather than a
404 (Not Found) for everything.

For example, attempting to DELETE on /v2/images will now return a 405
instead of a 404 and will provide a response header 'Allow' that lists
the valid methods for the resource.

Attempting to use NON_EXISTENT_METHOD on /v2/images will now return a
501.

Attempting to GET on /v2/non_existent_resource will, as expected, return
a 404.

Fixed for v1 and v2.

Change-Id: I5406f8ee423d3d5e66c56a26a7009b4f438a7e0f
Closes-Bug: #1297362
Improve Glance profiling

Put osprofiler middleware as a almost first middleware.
This allows us to:
1) Get more preciese duration. We are measuring duration of all middlewares.
2) authenticate middleware is requesting keystone, so if we init osprofiler
   before this middleware, we will get trace infomration from keystone as well.

Change-Id: I11c5d21e6e6b0bd514dee295da410b208d7c798c
Merge "Changes HTTP response code for unsupported methods"
Merge "Improved coverage for glance.api.*"
Merge "Improve Glance profiling"
Fix legacy tests using system policy.json file

Steps to reproduce:

1. Create a new file named '/etc/glance/policy.json' and inside it
paste:

    {"context_is_admin":  "role:admin"}

2. Run tests. Some of the tests under glance.tests.integration
.legacy_functional.test_v1_api will fail with errors such as
'MismatchError: 403 != 201'. These tests will pass without policy.json
in place.

The outcome of the tests should be isolated from the surrounding
environment, so this patch copies policy.json from glance's data files
(glance/tests/etc/policy.json) into the tests directory to avoid this
problem.

Change-Id: I27903ee4ebb7bad243c4f1b2d01096bfb93f1008
Closes-Bug: 1184056
Merge "Fix legacy tests using system policy.json file"