Use openstack.common.log to log request id

* Log request id from the request context for glance-api
  and glance-registry
* Further integrate with the common log module by storing RequestContext
  objects in thread-local storage so loggers can acces their attributes
* Move request id formatting into the request module so it appears with
  the preferred prefix (req-) in logs
* Implement bp glance-request-tracking

Change-Id: I2095ad16fef6b4bc8e49229c9f0326da8c743ff7
Move checked_iter from v1 API glance.api.common

The checked_iter image streaming wrapper should be in a common
place so the v2 API code can use it as well. This moves it to
glance/api/common.py and gives it a slightly more descriptive
name 'size_checked_iter'.

Change-Id: I9fbf2c76666bfc0b9227a6a6c4d824367526e56a
Fix registry error message and exception contents

The variable image_id should have been used instead of the global
identifier id

Fixes LP Bug #1026072

Change-Id: I2e73810e3165dd8b7032359b5fb8a874e592736f
Replace example.com with localhost for some tests

Fix for LP Bug #1025756.

When running the unit tests on a system without a
direct internet connection some tests run slowly.
Replacing example.com with localhost:0 speeds up
the relevant tests.

Change-Id: Iac6fc506b1d36b18ab21bb956ec2d8acc004bba8
Merge "Use openstack.common.log to log request id"
Dont show stack trace on command line for service error.

- Fix bug 996648

Currently if the Registry service is not running, any glance command
will show the Internal server error exception response body on the command line.
This fix proposes to hide that trace with a more generic message. Users can
still see the trace on log file in debug.

Change-Id: Ia86c42002ae8daabe0d7ad92a2017f1869b10853
Match path_info in image cache middleware

The url matching code in the image cache middleware should only look at
the unconsumed path, not the full path. Webob denotes this by using
'path_info' instead of 'path.'

This also adds some tests for the version negotiation middleware to ensure
it is returning a sane path for the image cache middleware to match.

Fixes bug 1026222

Change-Id: I522e2210e2b7272f9bb47602510a2910fa193415
Merge "Fix registry error message and exception contents"
Merge "Replace example.com with localhost for some tests"
Increase wait time for test_unsupported_default_store

Fix for LP Bug #1026047.

Allow unit test 'test_unsupported_default_store' to
successfully run on a slow machine.

Change-Id: I4d49c821aeb3027b7f33babf6c4bafe00644f0c9
Merge "Move checked_iter from v1 API glance.api.common"
Provide stores access to the request context.

Adds context to the constructor for the Store class. This can be used
to provide Store's access to the RequestContext.

Includes the following changes:

* Updates common store helper methods to create new instance of
  Store objects for each request.

* Updates Glance scrubber to create a real context from credentials.

The motivation for this change is that we will need access to the
service catalog and token for the Swift multi-tenant backend.

Partially implements blueprint: swift-tenant-specific-storage

Change-Id: I3def2b7c4085a36dd6c0961e762783ebaf7ffa74
Adds multi tenant support for swift backend.

Updates the swift store to support multiple tenants:

 * Added configuration option for swift_store_multi_tenant.

 * Updated the swift connection creation logic so that in multi-tenant
   mode the token and storage URL from the service catalog are used
   to create swift connection.

 * When in multi-tenant mode locations URL's (stored in the DB) do
   not contain hard coded swift credentials.

Includes unit tests to verify multi-tenant swift storage URLs.

Partially implements blueprint: swift-tenant-specific-storage.

Change-Id: I45fc97027e6f211ac353513c2d9d6da51ccf4489
Make functional tests listen on 127.0.0.1.

Fixes bug 987399.

Change-Id: I2a393d9b01c8ae17f289941530a1d4319b174f87
Honor '--insecure' commandline flag also for keystone authentication

Currently, keystone auth fails with self-signed certificates. This patch
essentially passes this value down to KeystoneStrategy._do_request. This
way, the '--insecure' flag is used by glanceclient to either validate
all SSL certificates or none. Fixes bug 1003711.

Change-Id: Ia9c9b762d2d474767984b4729bb50a8b78d6cb3f
Use size_checked_iter in v2 API

The image file returned in the v2 API should be treated the same
as in the v1 API. This patch wraps the returned image data in
the v2 API controller with glance.api.common.size_checked_iter

Change-Id: If7514a4394b17844d92b9737214898f954fe95a6
Set deleted_at field when image members and properties are deleted.

fixes bug 1028101

Change-Id: I3e9ffa9a97b57912d922ffadce31ed1ce0261fb4
Include chunk_name in swift debug message

Add chunk_name to swift upload debug message. Helps
to track which image the chunk is part of when several
uploads are occurring.

Fixes LP bug #1028433.

Change-Id: Ieacfd397939b77246e8c89214cbe902c3ed3e28c
Merge "Adds multi tenant support for swift backend."
Store swift images in separate containers.

Updates the swift storage backend so that when using multi tenant
each images gets stored in a separate container.

As part of this change the unit tests were updated to generate unique
swift container names for each test. This acts as a container prefix
in multi-tenant mode so the tests were also updated to cleanup all
swift containers matching the container name prefix as well.

The motivation for this change is so that we can set swift read/write
permissions on each individual image.

Partially implements blueprint: swift-tenant-specific-storage.

Change-Id: I43f33594fb40dee33ef52e8ae873722e20b09a10