From 06dd7f28d1d3ec8619df0d25ddfe977d538897b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mathieu=20Gagne=CC=81?= Date: Thu, 3 Jul 2014 15:30:05 -0400 Subject: [PATCH] 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 --- cinder/db/sqlalchemy/api.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 -- 2.45.2