]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
volume_image_metadata missing from volume list
authorMathieu Gagné <mgagne@iweb.com>
Thu, 3 Jul 2014 19:30:05 +0000 (15:30 -0400)
committerMathieu Gagné <mgagne@iweb.com>
Thu, 3 Jul 2014 19:31:04 +0000 (15:31 -0400)
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.

Change-Id: I6053708296f2b5e24513dc87ed63da0f67c220ae
Closes-bug: #1337526

cinder/db/sqlalchemy/api.py

index fd6e74bc508a5e5691947b69b7d6d04b40a41c92..914a9901090d3c4843c70c8f047e403a4d4eb593 100644 (file)
@@ -2407,14 +2407,12 @@ def volume_encryption_metadata_get(context, volume_id, session=None):
 
 @require_context
 def _volume_glance_metadata_get_all(context, session=None):
-    rows = model_query(context,
-                       models.VolumeGlanceMetadata,
-                       project_only=True,
-                       session=session).\
-        filter_by(deleted=False).\
-        all()
-
-    return rows
+    query = model_query(context,
+                        models.VolumeGlanceMetadata,
+                        session=session)
+    if is_user_context(context):
+        query = query.filter(models.Volume.project_id == context.project_id)
+    return query.all()
 
 
 @require_context