]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
RPC API: Clean up list_stacks results
authorZane Bitter <zbitter@redhat.com>
Fri, 21 Dec 2012 16:25:25 +0000 (17:25 +0100)
committerZane Bitter <zbitter@redhat.com>
Fri, 21 Dec 2012 17:48:57 +0000 (18:48 +0100)
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 <zbitter@redhat.com>
heat/api/cfn/v1/stacks.py
heat/api/openstack/v1/stacks.py
heat/engine/service.py
heat/tests/test_api_cfn_v1.py
heat/tests/test_api_openstack_v1.py
heat/tests/test_engine_service.py

index 31adeb944edf89f2bb8c7c67d979205ac4a0a86f..7c42a897e73642ff796fae1ef847638dae40e25a 100644 (file)
@@ -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)
 
index ab80f3299067bfd7650dbe43307bd9acbfc0abe7..3152916c1185a9b1ea1bb62c3fb0a82f9e131c69 100644 (file)
@@ -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
index ac864ca1a4973560aff696467f80cf2a023f592c..684e3800854a9dfedc96a569f1cfe185bc142aab 100644 (file)
@@ -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):
index 0baef2c7be8667b224497220f5adbc7acb89587a..ea4ea2da4e9cd6872571b63628d841d9a80f144d 100644 (file)
@@ -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',
index 6c728e5bc99090d9bfbd335ec395e50e2a5f11ae..dc0fde4ca97f0517a4279461d7145f355cb487a0 100644 (file)
@@ -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',
index eb3b5d161e2cd44b87fd0c57669edec4ff20e520..6583b1c71c1f1cfe7c7da3942192917cd8ae97d6 100644 (file)
@@ -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)