diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2012-10-25 23:44:34 -0700 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2012-10-27 14:18:19 -0700 |
| commit | 21b0bf7eeed72dffa2628dc8ebb7d0c6e371cc1c (patch) | |
| tree | 9ba31bdbdb0416719d56ece4ee5fda74f975b5ac /nova/db | |
| parent | 07fb04a00b00ec58f3ecf7a40abd6b7161915cac (diff) | |
Make instance_get_all() not require admin context
Helps to clean up tests which use this method.
Change-Id: Ic707b1d1b679b983b4d2b7dcad5a5a33ed771d3c
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 888bb83a5..da8c559c6 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1519,7 +1519,7 @@ def _build_instance_get(context, session=None): options(joinedload('instance_type')) -@require_admin_context +@require_context def instance_get_all(context, columns_to_join=None): if columns_to_join is None: columns_to_join = ['info_cache', 'security_groups', @@ -1527,6 +1527,12 @@ def instance_get_all(context, columns_to_join=None): query = model_query(context, models.Instance) for column in columns_to_join: query = query.options(joinedload(column)) + if not context.is_admin: + # If we're not admin context, add appropriate filter.. + if context.project_id: + query = query.filter_by(project_id=context.project_id) + else: + query = query.filter_by(user_id=context.user_id) return query.all() |
