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 <shardy@redhat.com>
This commit is contained in:
parent
66ef27527d
commit
ee9e31fb1f
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue