Add show_nested to count_stacks RPC interface

blueprint: list-nested
Change-Id: I60c25a34009028d45d73a10fe372abdf28ef043f
This commit is contained in:
Steven Hardy 2014-08-14 11:30:22 +01:00
parent a2081e4773
commit 0581a2447a
4 changed files with 24 additions and 7 deletions

View File

@ -461,18 +461,20 @@ class EngineService(service.Service):
@request_context
def count_stacks(self, cnxt, filters=None, tenant_safe=True,
show_deleted=False):
show_deleted=False, show_nested=False):
"""
Return the number of stacks that match the given filters
:param ctxt: RPC context.
:param filters: a dict of ATTR:VALUE to match against stacks
:param tenant_safe: if true, scope the request by the current tenant
:param show_deleted: if true, count will include the deleted stacks
:param show_nested: if true, count will include nested stacks
:returns: a integer representing the number of matched stacks
"""
return db_api.stack_count_all(cnxt, filters=filters,
tenant_safe=tenant_safe,
show_deleted=show_deleted)
show_deleted=show_deleted,
show_nested=show_nested)
def _validate_deferred_auth_context(self, cnxt, stack):
if cfg.CONF.deferred_auth_method != 'password':

View File

@ -97,19 +97,21 @@ class EngineClient(object):
show_nested=show_nested))
def count_stacks(self, ctxt, filters=None, tenant_safe=True,
show_deleted=False):
show_deleted=False, show_nested=False):
"""
Return the number of stacks that match the given filters
:param ctxt: RPC context.
:param filters: a dict of ATTR:VALUE to match against stacks
:param tenant_safe: if true, scope the request by the current tenant
:param show_deleted: if true, count will include the deleted stacks
:param show_nested: if true, count will include nested stacks
:returns: a integer representing the number of matched stacks
"""
return self.call(ctxt, self.make_msg('count_stacks',
filters=filters,
tenant_safe=tenant_safe,
show_deleted=show_deleted))
show_deleted=show_deleted,
show_nested=show_nested))
def show_stack(self, ctxt, stack_identity):
"""

View File

@ -1838,7 +1838,8 @@ class StackServiceTest(HeatTestCase):
mock_stack_count_all.assert_called_once_with(mock.ANY,
filters={'foo': 'bar'},
tenant_safe=mock.ANY,
show_deleted=False)
show_deleted=False,
show_nested=False)
@mock.patch.object(db_api, 'stack_count_all')
def test_count_stacks_tenant_safe_default_true(self, mock_stack_count_all):
@ -1846,7 +1847,8 @@ class StackServiceTest(HeatTestCase):
mock_stack_count_all.assert_called_once_with(mock.ANY,
filters=mock.ANY,
tenant_safe=True,
show_deleted=False)
show_deleted=False,
show_nested=False)
@mock.patch.object(db_api, 'stack_count_all')
def test_count_stacks_passes_tenant_safe_info(self, mock_stack_count_all):
@ -1854,7 +1856,17 @@ class StackServiceTest(HeatTestCase):
mock_stack_count_all.assert_called_once_with(mock.ANY,
filters=mock.ANY,
tenant_safe=False,
show_deleted=False)
show_deleted=False,
show_nested=False)
@mock.patch.object(db_api, 'stack_count_all')
def test_count_stacks_show_nested(self, mock_stack_count_all):
self.eng.count_stacks(self.ctx, show_nested=True)
mock_stack_count_all.assert_called_once_with(mock.ANY,
filters=mock.ANY,
tenant_safe=True,
show_deleted=False,
show_nested=True)
@stack_context('service_abandon_stack')
def test_abandon_stack(self):

View File

@ -92,6 +92,7 @@ class EngineRpcAPITestCase(testtools.TestCase):
'filters': mock.ANY,
'tenant_safe': mock.ANY,
'show_deleted': mock.ANY,
'show_nested': mock.ANY,
}
self._test_engine_api('count_stacks', 'call', **default_args)