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>
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):
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