]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix DescribeStacks command for all stacks
authorZane Bitter <zbitter@redhat.com>
Wed, 19 Dec 2012 17:48:26 +0000 (18:48 +0100)
committerZane Bitter <zbitter@redhat.com>
Wed, 19 Dec 2012 18:58:14 +0000 (19:58 +0100)
Fixes: bug 1092196
Change-Id: I05065c08b4072a9c179ebfb36fb15f062de3f06e
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/engine/service.py
heat/rpc/client.py
heat/tests/test_engine_service.py

index 5a324e888f25524987254ec382271bc551d3bab7..a2c35a17c4220af281d783f8d9ec5f1d27e74f0d 100644 (file)
@@ -142,14 +142,14 @@ class EngineService(service.Service):
     @request_context
     def show_stack(self, context, stack_identity):
         """
-        The show_stack method returns the attributes of one stack.
+        Return detailed information about one or all stacks.
         arg1 -> RPC context.
-        arg2 -> Name of the stack you want to see
+        arg2 -> Name of the stack you want to show, or None to show all
         """
-        if stack_identity is None:
-            raise AttributeError('No stack_identity provided')
-
-        stacks = [self._get_stack(context, stack_identity)]
+        if stack_identity is not None:
+            stacks = [self._get_stack(context, stack_identity)]
+        else:
+            stacks = db_api.stack_get_all_by_tenant(context) or []
 
         def format_stack_detail(s):
             stack = parser.Stack.load(context, stack=s)
index 839fad1ee5b80aa9ed2945205787c902c4c02463..b39583f0ab238953f01897ecb71899b428616f77 100644 (file)
@@ -79,11 +79,10 @@ class EngineClient(heat.openstack.common.rpc.proxy.RpcProxy):
 
     def show_stack(self, ctxt, stack_identity):
         """
-        The show_stack method returns the attributes of one stack.
-
+        Return detailed information about one or all stacks.
         :param ctxt: RPC context.
-        :param stack_identity: Name of the stack you want to see,
-                           or None to see all
+        :param stack_identity: Name of the stack you want to show, or None to
+                               show all
         """
         return self.call(ctxt, self.make_msg('show_stack',
                                              stack_identity=stack_identity),
index e945c6ae83fa60adff5e1f7a2db1131923528be2..c53a05ced5d7e5e854d2757c6e7bc90098d961a7 100644 (file)
@@ -463,17 +463,25 @@ class stackServiceTest(unittest.TestCase):
 
             self.assertTrue('event_time' in ev)
 
-    def test_stack_describe_all(self):
+    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.assertTrue('creation_time' in s)
+            self.assertTrue('updated_time' in s)
+            self.assertTrue('stack_identity' in s)
             self.assertNotEqual(s['stack_identity'], None)
+            self.assertTrue('stack_name' in s)
+            self.assertEqual(s['stack_name'], self.stack_name)
+            self.assertTrue('stack_status' in s)
+            self.assertTrue('stack_status_reason' in s)
+            self.assertTrue('description' in s)
             self.assertNotEqual(s['description'].find('WordPress'), -1)
 
-    def test_stack_describe_all_empty(self):
+    def test_stack_list_all_empty(self):
         self.tearDown()
-        self.tenant = 'stack_describe_all_empty_tenant'
+        self.tenant = 'stack_list_all_empty_tenant'
         self.setUp()
 
         sl = self.man.list_stacks(self.ctx)
@@ -505,6 +513,33 @@ class stackServiceTest(unittest.TestCase):
         self.assertNotEqual(s['description'].find('WordPress'), -1)
         self.assertTrue('parameters' in s)
 
+    def test_stack_describe_all(self):
+        sl = self.man.show_stack(self.ctx, None)
+
+        self.assertEqual(len(sl['stacks']), 1)
+
+        s = sl['stacks'][0]
+        self.assertTrue('creation_time' in s)
+        self.assertTrue('updated_time' in s)
+        self.assertTrue('stack_identity' in s)
+        self.assertNotEqual(s['stack_identity'], None)
+        self.assertTrue('stack_name' in s)
+        self.assertEqual(s['stack_name'], self.stack_name)
+        self.assertTrue('stack_status' in s)
+        self.assertTrue('stack_status_reason' in s)
+        self.assertTrue('description' in s)
+        self.assertNotEqual(s['description'].find('WordPress'), -1)
+        self.assertTrue('parameters' in s)
+
+    def test_stack_describe_all_empty(self):
+        self.tearDown()
+        self.tenant = 'stack_describe_all_empty_tenant'
+        self.setUp()
+
+        sl = self.man.show_stack(self.ctx, None)
+
+        self.assertEqual(len(sl['stacks']), 0)
+
     def test_list_resource_types(self):
         resources = self.man.list_resource_types(self.ctx)
         self.assertTrue(isinstance(resources, list))