Add more per-user stack support (2).

This finishes up the API calls with per-user returns of stacks and
events.

Change-Id: Iab6118f35978a6f62ad4d3454842cb7f3d686bc8
Signed-off-by: Ian Main <imain@redhat.com>
changes/94/194/1
Ian Main 10 years ago
parent d09bad5bef
commit b40d770864
  1. 4
      heat/db/api.py
  2. 11
      heat/db/sqlalchemy/api.py
  3. 4
      heat/engine/manager.py

@ -140,6 +140,10 @@ def event_get_all(context):
return IMPL.event_get_all(context)
def event_get_all_by_user(context):
return IMPL.event_get_all_by_user(context)
def event_get_all_by_stack(context, stack_id):
return IMPL.event_get_all_by_stack(context, stack_id)

@ -226,6 +226,17 @@ def event_get_all(context):
return results
def event_get_all_by_user(context):
stacks = model_query(context, models.Stack).\
filter_by(username=context.username).all()
results = []
for stack in stacks:
results.extend(model_query(context, models.Event).\
filter_by(stack_id=stack.id).all())
return results
def event_get_all_by_stack(context, stack_id):
results = model_query(context, models.Event).\
filter_by(stack_id=stack_id).all()

@ -299,7 +299,7 @@ class EngineManager(manager.Manager):
arg3 -> Dict of http request parameters passed in from API side.
"""
self._authenticate(context)
s = db_api.stack_get_by_name(None, stack_name)
s = db_api.stack_get_by_name(context, stack_name)
if s:
return s.raw_template.template
return None
@ -357,7 +357,7 @@ class EngineManager(manager.Manager):
events = db_api.event_get_all_by_stack(context, st.id)
else:
events = db_api.event_get_all(context)
events = db_api.event_get_all_by_user(context)
return {'events': [self.parse_event(e) for e in events]}

Loading…
Cancel
Save