From ee9e31fb1fd502ed0ddee74d6f41b65a7e6ecf91 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 21 Nov 2012 11:31:14 +0000 Subject: [PATCH] heat engine Add admin flag to dbapi stack_get Add a flag to the stack_get dbapi call, defaulted to False, which allows us to specify that the admin context is being used hence we don't want tenant-scoping condition applied. This is needed to allow the admin context to retrieve stored credentials per-stack (e.g for the periodic per-stack tasks) Change-Id: I55e307b7940f7da13bd169271744e80d95ea0bd9 Signed-off-by: Steven Hardy --- heat/db/api.py | 4 ++-- heat/db/sqlalchemy/api.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/heat/db/api.py b/heat/db/api.py index 14ca76c2..22664e56 100644 --- a/heat/db/api.py +++ b/heat/db/api.py @@ -86,8 +86,8 @@ def resource_get_by_physical_resource_id(context, physical_resource_id): physical_resource_id) -def stack_get(context, stack_id): - return IMPL.stack_get(context, stack_id) +def stack_get(context, stack_id, admin=False): + return IMPL.stack_get(context, stack_id, admin) def stack_get_by_name(context, stack_name): diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py index 57680b22..b0cede53 100644 --- a/heat/db/sqlalchemy/api.py +++ b/heat/db/sqlalchemy/api.py @@ -121,9 +121,14 @@ def stack_get_by_name(context, stack_name, owner_id=None): return query.first() -def stack_get(context, stack_id): +def stack_get(context, stack_id, admin=False): result = model_query(context, models.Stack).get(stack_id) + # If the admin flag is True, we allow retrieval of a specific + # stack without the tenant scoping + if admin: + return result + if (result is not None and context is not None and result.tenant != context.tenant_id): return None -- 2.45.2