API changes for param to show soft-deleted stacks
blueprint stack-list-soft-deleted Change-Id: I9b56ee877746c25c6acefb91fc3eae63701aedd6
This commit is contained in:
parent
4e38944279
commit
ffb918188f
@ -161,10 +161,15 @@ class StackController(object):
|
||||
'marker': 'single',
|
||||
'sort_dir': 'single',
|
||||
'sort_keys': 'multi',
|
||||
'show_deleted': 'single',
|
||||
}
|
||||
params = util.get_allowed_params(req.params, whitelist)
|
||||
filter_params = util.get_allowed_params(req.params, filter_whitelist)
|
||||
|
||||
if engine_api.PARAM_SHOW_DELETED in params:
|
||||
show_del = util.extract_bool(params[engine_api.PARAM_SHOW_DELETED])
|
||||
params[engine_api.PARAM_SHOW_DELETED] = show_del
|
||||
|
||||
if not filter_params:
|
||||
filter_params = None
|
||||
|
||||
|
@ -14,9 +14,11 @@
|
||||
ENGINE_TOPIC = 'engine'
|
||||
|
||||
PARAM_KEYS = (
|
||||
PARAM_TIMEOUT, PARAM_DISABLE_ROLLBACK, PARAM_ADOPT_STACK_DATA
|
||||
PARAM_TIMEOUT, PARAM_DISABLE_ROLLBACK, PARAM_ADOPT_STACK_DATA,
|
||||
PARAM_SHOW_DELETED
|
||||
) = (
|
||||
'timeout_mins', 'disable_rollback', 'adopt_stack_data'
|
||||
'timeout_mins', 'disable_rollback', 'adopt_stack_data',
|
||||
'show_deleted'
|
||||
)
|
||||
|
||||
STACK_KEYS = (
|
||||
|
@ -51,7 +51,8 @@ class EngineClient(heat.openstack.common.rpc.proxy.RpcProxy):
|
||||
stack_name=stack_name))
|
||||
|
||||
def list_stacks(self, ctxt, limit=None, marker=None, sort_keys=None,
|
||||
sort_dir=None, filters=None, tenant_safe=True):
|
||||
sort_dir=None, filters=None, tenant_safe=True,
|
||||
show_deleted=False):
|
||||
"""
|
||||
The list_stacks method returns attributes of all stacks. It supports
|
||||
pagination (``limit`` and ``marker``), sorting (``sort_keys`` and
|
||||
@ -64,12 +65,15 @@ class EngineClient(heat.openstack.common.rpc.proxy.RpcProxy):
|
||||
:param sort_dir: the direction of the sort ('asc' or 'desc')
|
||||
:param filters: a dict with attribute:value to filter the list
|
||||
:param tenant_safe: if true, scope the request by the current tenant
|
||||
:param show_deleted: if true, show soft-deleted stacks
|
||||
:returns: a list of stacks
|
||||
"""
|
||||
return self.call(ctxt, self.make_msg('list_stacks', limit=limit,
|
||||
sort_keys=sort_keys, marker=marker,
|
||||
sort_dir=sort_dir, filters=filters,
|
||||
tenant_safe=tenant_safe))
|
||||
return self.call(ctxt,
|
||||
self.make_msg('list_stacks', limit=limit,
|
||||
sort_keys=sort_keys, marker=marker,
|
||||
sort_dir=sort_dir, filters=filters,
|
||||
tenant_safe=tenant_safe,
|
||||
show_deleted=show_deleted))
|
||||
|
||||
def count_stacks(self, ctxt, filters=None, tenant_safe=True):
|
||||
"""
|
||||
|
@ -158,7 +158,8 @@ class CfnStackControllerTest(HeatTestCase):
|
||||
u'StackStatus': u'CREATE_COMPLETE'}]}}}
|
||||
self.assertEqual(expected, result)
|
||||
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True}
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True,
|
||||
'show_deleted': False}
|
||||
mock_call.assert_called_once_with(dummy_req.context, self.topic,
|
||||
{'namespace': None,
|
||||
'method': 'list_stacks',
|
||||
|
@ -373,7 +373,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
}
|
||||
self.assertEqual(expected, result)
|
||||
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True}
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True,
|
||||
'show_deleted': False}
|
||||
mock_call.assert_called_once_with(req.context, self.topic,
|
||||
{'namespace': None,
|
||||
'method': 'list_stacks',
|
||||
@ -398,7 +399,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
|
||||
rpc_call_args, _ = mock_call.call_args
|
||||
engine_args = rpc_call_args[2]['args']
|
||||
self.assertEqual(6, len(engine_args))
|
||||
self.assertEqual(7, len(engine_args))
|
||||
self.assertIn('limit', engine_args)
|
||||
self.assertIn('sort_keys', engine_args)
|
||||
self.assertIn('marker', engine_args)
|
||||
@ -498,6 +499,32 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
filters=mock.ANY,
|
||||
tenant_safe=False)
|
||||
|
||||
def test_global_index_show_deleted_false(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
rpc_client.count_stacks = mock.Mock()
|
||||
|
||||
params = {'show_deleted': 'False'}
|
||||
req = self._get('/stacks', params=params)
|
||||
self.controller.index(req, tenant_id=self.tenant)
|
||||
rpc_client.list_stacks.assert_called_once_with(mock.ANY,
|
||||
filters=mock.ANY,
|
||||
tenant_safe=True,
|
||||
show_deleted=False)
|
||||
|
||||
def test_global_index_show_deleted_True(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
rpc_client.count_stacks = mock.Mock()
|
||||
|
||||
params = {'show_deleted': 'True'}
|
||||
req = self._get('/stacks', params=params)
|
||||
self.controller.index(req, tenant_id=self.tenant)
|
||||
rpc_client.list_stacks.assert_called_once_with(mock.ANY,
|
||||
filters=mock.ANY,
|
||||
tenant_safe=True,
|
||||
show_deleted=True)
|
||||
|
||||
@mock.patch.object(rpc, 'call')
|
||||
def test_detail(self, mock_call, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'detail', True)
|
||||
@ -553,7 +580,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
|
||||
self.assertEqual(expected, result)
|
||||
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True}
|
||||
'sort_dir': None, 'filters': None, 'tenant_safe': True,
|
||||
'show_deleted': False}
|
||||
mock_call.assert_called_once_with(req.context, self.topic,
|
||||
{'namespace': None,
|
||||
'method': 'list_stacks',
|
||||
|
@ -89,6 +89,7 @@ class EngineRpcAPITestCase(testtools.TestCase):
|
||||
'sort_dir': mock.ANY,
|
||||
'filters': mock.ANY,
|
||||
'tenant_safe': mock.ANY,
|
||||
'show_deleted': mock.ANY,
|
||||
}
|
||||
self._test_engine_api('list_stacks', 'call', **default_args)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user