volume_image_metadata missing from volume list

The volume_image_metadata field was missing from the volume list
because we tried to filter VolumeGlanceMetadata against a non-existent
project_id field. Filtering should be done on the Volume associated
to the VolumeGlanceMetadata instead.

Move project_id filtering out of model_query as it assumes
the project_id field is in the queried model itself.
Build the filter ourselves against Volume.

Fix glance metadata SQL query performance

The query built to retrieve glance metadata associated to a volume
was sub-optimal: all rows of volume_glance_metadata were returned.

Fix it by properly joining the 2 tables with volume_id field.

Closes-bug: #1337526
Closes-bug: #1349936
Change-Id: I6053708296f2b5e24513dc87ed63da0f67c220ae
(cherry picked from commit 06dd7f28d1d3ec8619df0d25ddfe977d538897b3)
(cherry picked from commit 8f8a8a6ffe14cf7bb461dc26d178bf8acc8ddf12)
Prevent tenant viewing volumes owned by another

Bug introduced by 0505bb268942534ad5d6ecd5e34a4d9b0e7f5c04 allows any
tenant to get the details of a volume belonging to any other tenant
if the UUID is known.

This commit allows only the tenant or an admin to get a volume.

Change-Id: I0268d374f7529d89068dcbf3c1cb9ab3d60d4115
Closes-Bug: #1356368
(cherry picked from commit 5868e8f285d23b56ca6123dab760342c57bf8c80)
NetApp NFS: Do not reference dst_img_local before assignment

This patch moves the assignment of the dst_img_local variable to before the
try/finally block that references it so that the finally block will have this
variable no matter where in the try block an error is raised.

Change-ID: Iab48b46559f18a3d6b044abe4bc3e615e7fee075
Closes-Bug: 1309047
(cherry-picked from commit 48a53d32ee243d80b034b38e292e9bfb4b66f881)
Fixes terminate_connection live migration issue

Reverts the changes to cinder/volume/manager.py added in
commit b868ae707f9ecbe254101e21d9d7ffa0b05b17d1 as calling
remove_export in terminate_connection causes Nova live
migration to fail when volumes are attached.

Conflicts:
        cinder/volume/manager.py

Change-Id: I38f3db336db22bb096a8855bcbbfeba16e517b80
Closes-Bug: #1361738
(cherry picked from ddcad011db507cde66b6b1e655d5ffc91ab8880f)
Merge "volume_image_metadata missing from volume list" into stable/icehouse
Merge "NetApp NFS: Do not reference dst_img_local before assignment" into stable/icehouse
Merge "Fixes terminate_connection live migration issue" into stable/icehouse
Merge "Prevent tenant viewing volumes owned by another" into stable/icehouse