From: Zane Bitter Date: Fri, 21 Dec 2012 16:25:25 +0000 (+0100) Subject: RPC API: Clean up list_stacks results X-Git-Tag: 2014.1~1043 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ee208680d8924e78dad4e6b5f9e287a31b5940f3;p=openstack-build%2Fheat-build.git RPC API: Clean up list_stacks results Just return a list, rather than wrapping it in an object. The client API processes can (and do) do whatever wrapping they need. Change-Id: I4a8e64e8e4a0f127e8fa5c12738353a1f3a0c22f Signed-off-by: Zane Bitter --- diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 31adeb94..7c42a897 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -127,8 +127,7 @@ class StackController(object): except rpc_common.RemoteError as ex: return exception.map_remote_error(ex) - res = {'StackSummaries': [format_stack_summary(s) - for s in stack_list['stacks']]} + res = {'StackSummaries': [format_stack_summary(s) for s in stack_list]} return api_utils.format_response('ListStacks', res) diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index ab80f329..3152916c 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -151,7 +151,7 @@ class StackController(object): """ try: - stack_list = self.engine.list_stacks(req.context) + stacks = self.engine.list_stacks(req.context) except rpc_common.RemoteError as ex: return util.remote_error(ex, True) @@ -164,8 +164,6 @@ class StackController(object): engine_api.STACK_DELETION_TIME, engine_api.STACK_UPDATED_TIME) - stacks = stack_list['stacks'] - return {'stacks': [format_stack(req, s, summary_keys) for s in stacks]} @util.tenant_local diff --git a/heat/engine/service.py b/heat/engine/service.py index ac864ca1..684e3800 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -177,7 +177,7 @@ class EngineService(service.Service): yield api.format_stack(stack) stacks = db_api.stack_get_all_by_tenant(context) or [] - return {'stacks': list(format_stack_details(stacks))} + return list(format_stack_details(stacks)) @request_context def create_stack(self, context, stack_name, template, params, args): diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index 0baef2c7..ea4ea2da 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -77,8 +77,7 @@ class StackControllerTest(unittest.TestCase): dummy_req = self._dummy_GET_request(params) # Stub out the RPC call to the engine with a pre-canned response - engine_resp = {u'stacks': [ - {u'stack_identity': {u'tenant': u't', + engine_resp = [{u'stack_identity': {u'tenant': u't', u'stack_name': u'wordpress', u'stack_id': u'1', u'path': u''}, @@ -87,7 +86,7 @@ class StackControllerTest(unittest.TestCase): u'stack_status_reason': u'Stack successfully created', u'creation_time': u'2012-07-09T09:12:45Z', u'stack_name': u'wordpress', - u'stack_status': u'CREATE_COMPLETE'}]} + u'stack_status': u'CREATE_COMPLETE'}] self.m.StubOutWithMock(rpc, 'call') rpc.call(dummy_req.context, self.topic, {'method': 'list_stacks', diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py index 6c728e5b..dc0fde4c 100644 --- a/heat/tests/test_api_openstack_v1.py +++ b/heat/tests/test_api_openstack_v1.py @@ -240,26 +240,24 @@ class StackControllerTest(ControllerTest, unittest.TestCase): identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '1') - engine_resp = { - u'stacks': [ - { - u'stack_identity': dict(identity), - u'updated_time': u'2012-07-09T09:13:11Z', - u'template_description': u'blah', - u'description': u'blah', - u'stack_status_reason': u'Stack successfully created', - u'creation_time': u'2012-07-09T09:12:45Z', - u'stack_name': identity.stack_name, - u'stack_status': u'CREATE_COMPLETE', - u'parameters': {}, - u'outputs': [], - u'notification_topics': [], - u'capabilities': [], - u'disable_rollback': True, - u'timeout_mins': 60, - } - ] - } + engine_resp = [ + { + u'stack_identity': dict(identity), + u'updated_time': u'2012-07-09T09:13:11Z', + u'template_description': u'blah', + u'description': u'blah', + u'stack_status_reason': u'Stack successfully created', + u'creation_time': u'2012-07-09T09:12:45Z', + u'stack_name': identity.stack_name, + u'stack_status': u'CREATE_COMPLETE', + u'parameters': {}, + u'outputs': [], + u'notification_topics': [], + u'capabilities': [], + u'disable_rollback': True, + u'timeout_mins': 60, + } + ] self.m.StubOutWithMock(rpc, 'call') rpc.call(req.context, self.topic, {'method': 'list_stacks', diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index eb3b5d16..6583b1c7 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -468,8 +468,8 @@ class stackServiceTest(unittest.TestCase): def test_stack_list_all(self): sl = self.man.list_stacks(self.ctx) - self.assertEqual(len(sl['stacks']), 1) - for s in sl['stacks']: + self.assertEqual(len(sl), 1) + for s in sl: self.assertTrue('creation_time' in s) self.assertTrue('updated_time' in s) self.assertTrue('stack_identity' in s) @@ -488,7 +488,7 @@ class stackServiceTest(unittest.TestCase): sl = self.man.list_stacks(self.ctx) - self.assertEqual(len(sl['stacks']), 0) + self.assertEqual(len(sl), 0) def test_stack_describe_nonexistent(self): nonexist = dict(self.stack_identity)