db API add show_nested to stack_count_all
blueprint: list-nested Change-Id: I38e3bcba2e75253a3e77fd31f9db103f3ebab7b6
This commit is contained in:
parent
b4fb37e16b
commit
a2081e4773
@ -135,10 +135,11 @@ def stack_get_all_by_owner_id(context, owner_id):
|
||||
|
||||
|
||||
def stack_count_all(context, filters=None, tenant_safe=True,
|
||||
show_deleted=False):
|
||||
show_deleted=False, show_nested=False):
|
||||
return IMPL.stack_count_all(context, filters=filters,
|
||||
tenant_safe=tenant_safe,
|
||||
show_deleted=show_deleted)
|
||||
show_deleted=show_deleted,
|
||||
show_nested=show_nested)
|
||||
|
||||
|
||||
def stack_create(context, values):
|
||||
|
@ -381,9 +381,10 @@ def _filter_and_page_query(context, query, limit=None, sort_keys=None,
|
||||
|
||||
|
||||
def stack_count_all(context, filters=None, tenant_safe=True,
|
||||
show_deleted=False):
|
||||
show_deleted=False, show_nested=False):
|
||||
query = _query_stack_get_all(context, tenant_safe=tenant_safe,
|
||||
show_deleted=show_deleted)
|
||||
show_deleted=show_deleted,
|
||||
show_nested=show_nested)
|
||||
query = db_filters.exact_filter(query, models.Stack, filters)
|
||||
return query.count()
|
||||
|
||||
|
@ -582,6 +582,21 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
st_db = db_api.stack_count_all(self.ctx, filters=filters)
|
||||
self.assertEqual(2, st_db)
|
||||
|
||||
def test_stack_count_all_show_nested(self):
|
||||
stack1 = self._setup_test_stack('stack1', UUID1)[1]
|
||||
self._setup_test_stack('stack2', UUID2,
|
||||
owner_id=stack1.id)
|
||||
# Backup stack should not be counted
|
||||
self._setup_test_stack('stack1*', UUID3,
|
||||
owner_id=stack1.id,
|
||||
backup=True)
|
||||
|
||||
st_db = db_api.stack_count_all(self.ctx)
|
||||
self.assertEqual(1, st_db)
|
||||
|
||||
st_db = db_api.stack_count_all(self.ctx, show_nested=True)
|
||||
self.assertEqual(2, st_db)
|
||||
|
||||
def test_event_get_all_by_stack(self):
|
||||
stack = self._setup_test_stack('stack', UUID1)[1]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user