Honor metadata_encryption_key in glance domain

Since v2 is not using the registry client, it was not properly
encrypting image locations before storing them in the database. With
this change, the db layer in the glance domain now uses the metadata
encryption key as well.

To make this work, the declaration of the metadata_encryption_key option
had to move to glance.common.config to avoid circular module
dependencies.

Fixes bug 1128650

Change-Id: I3bb5da92ffda7bfe1bc064d11da8ecd4e6d9ab1d
Fix check_003 method.

This commit fixes the check on migration 003 in test_migrations.
Previously, when this method was added it didn't check that the
data in the type column previously in the images table was moved
correctly into the image_properties table. This commit adds these
data checks.

Change-Id: Ia3906c8497218c8a3d2a13b0c99a6aa566977ed4
Insure that migration 6 retains deleted image property index.

Migration 6 for sqlite deletes the entire table and then recreates it,
however it fails to create the image_properties deleted index.

Fixes bug: 1051123

Change-Id: I4740ff1d5b9ec44067e6af7dd822329105222690
Fix circular import in glance/db/sqlalchemy

Fix running test_migration solely.

api.py depends on models.py that depends on api.py.
Import statements in these files are such that api.py
must be imported before models.py. That's why usually
test_migrations doesn't fail when all tests are launched.
However, thus test_migration depends on test running order
making testing procedure unreliable, including parallel testing.

Move glance.db.sqlalchemy.api import to the only place
where it's required in models.py

Change-Id: Ib20dde8edd3473595aac1ca8bbaa5a0d3116a697
Fixes: bug #1154058
Publish API version 2.1

Fixes bug 1154317.

Change-Id: I1e044539952f649974c757183e9bb2551264850e
Log when image_size_cap has been exceeded

Add a log entry when an attempt to upload an image whose size is greater
than image_size_cap has been made.

Addresses bug 1154606.

Change-Id: I836cb2dad1c130c0df15d26a87229b60a6cc3033
Merge "Honor metadata_encryption_key in glance domain"
Merge "Publish API version 2.1"
Merge "Insure that migration 6 retains deleted image property index."
Merge "Log when image_size_cap has been exceeded"
Declare index on ImageMember model

This index was added in migration 008. However, it was not on the model,
which meant any autocreated db would not have it.

Fixes bug 1154777

Change-Id: I34590ffebaf547be9a12e5a85216cda145d9e8db
Merge "Fix circular import in glance/db/sqlalchemy"
Merge "Fix check_003 method."
Merge "Declare index on ImageMember model"
Fix uniqueness constraint on image_members table.

Fixes bug #1098700.

Previously, deleting then re-creating an image member failed with
500 ServerError due to the registry service failing to commit
the update to the image_members table.

The problem arose because the declared uniqueness constraint on that
table only spanned the image_id and member columns, but did not take
into account that deleted rows are left in situ with the deleted_at
and deleted columns set as appropriate. Hence the unique constraint
was violated by the addition of the new row.

We modify the uniqueness constraint via a migration script to take
account of the deleted_at column also (NULL for live memberships).

Note that the new ability to recreate an image membership cannot be
be asserted in a functional test, as these tests are based on sqlite
which does not support 'ALTER TABLE DROP CONSTRAINT'.

Change-Id: I175801ba95ecd9295791bb12e9096f59efa19c02