Handle NotFound in Stack get_all

As we don't have transactions and we're loading the templates
seperately, they can be gone by the time we load the stack. Let's ignore
NotFound errors in that case.

Change-Id: I048b4fb50512478a514f245b618784f1d7eb0c1d
Closes-Bug: #1537627
This commit is contained in:
Thomas Herve 2016-01-25 08:53:37 +01:00
parent ec6c940b80
commit 3f519dfe0f
1 changed files with 10 additions and 6 deletions

View File

@ -116,16 +116,20 @@ class Stack(
@classmethod
def get_all(cls, context, *args, **kwargs):
db_stacks = db_api.stack_get_all(context, *args, **kwargs)
stacks = [cls._from_db_object(context, cls(context), db_stack)
for db_stack in db_stacks]
return stacks
for db_stack in db_stacks:
try:
yield cls._from_db_object(context, cls(context), db_stack)
except exception.NotFound:
pass
@classmethod
def get_all_by_owner_id(cls, context, owner_id):
db_stacks = db_api.stack_get_all_by_owner_id(context, owner_id)
stacks = [cls._from_db_object(context, cls(context), db_stack)
for db_stack in db_stacks]
return stacks
for db_stack in db_stacks:
try:
yield cls._from_db_object(context, cls(context), db_stack)
except exception.NotFound:
pass
@classmethod
def count_all(cls, context, **kwargs):