From: Mathieu Gagné Date: Thu, 3 Jul 2014 19:30:05 +0000 (-0400) Subject: volume_image_metadata missing from volume list X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=06dd7f28d1d3ec8619df0d25ddfe977d538897b3;p=openstack-build%2Fcinder-build.git 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. Change-Id: I6053708296f2b5e24513dc87ed63da0f67c220ae Closes-bug: #1337526 --- diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index fd6e74bc5..914a99010 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -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