]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat cli : Workaround inconsistent boto return type
authorSteven Hardy <shardy@redhat.com>
Wed, 15 Aug 2012 14:16:23 +0000 (15:16 +0100)
committerSteven Hardy <shardy@redhat.com>
Thu, 16 Aug 2012 12:02:09 +0000 (13:02 +0100)
Work around the inconsistent boto return type for DescribeStackResource
action, upstream patch pending but not yet merged, so this provides
a simple workaround

Fixes #175

Change-Id: I026ec7b1845fb591a47a5fb12cfcb25705b33909
Signed-off-by: Steven Hardy <shardy@redhat.com>
bin/heat
heat/boto_client.py
heat/client.py

index fbfb305130406ea617c173e45f324faa75be6315..90dc28ba45577a9f8433695247b7a0612b695474 100755 (executable)
--- a/bin/heat
+++ b/bin/heat
@@ -277,7 +277,7 @@ def stack_resource_show(options, arguments):
         'LogicalResourceId': resource_name,
     }
     result = c.describe_stack_resource(**parameters)
-    print c.format_stack_resource(result)
+    print c.format_stack_resource_detail(result)
 
 
 @utils.catch_error('resource-list')
index b296371d07445a523b62382e05306df93f374244..7b5d84d03d8dbb15cdb64234a4fd806e1c7918da 100644 (file)
@@ -21,6 +21,7 @@ from heat.openstack.common import log as logging
 logger = logging.getLogger(__name__)
 
 from boto.cloudformation import CloudFormationConnection
+import json
 
 
 class BotoClient(CloudFormationConnection):
@@ -203,6 +204,24 @@ class BotoClient(CloudFormationConnection):
             ret.append("--")
         return '\n'.join(ret)
 
+    def format_stack_resource_detail(self, res):
+        '''
+        Print response from describe_stack_resource call
+
+        Note pending upstream patch will make this response a
+        boto.cloudformation.stack.StackResourceDetail object
+        which aligns better with all the existing calls
+        see https://github.com/boto/boto/pull/857
+
+        For now, we format the dict response as a workaround
+        '''
+        resource_detail = res['DescribeStackResourceResponse'][
+                   'DescribeStackResourceResult']['StackResourceDetail']
+        ret = []
+        for key in resource_detail:
+            ret.append("%s : %s" % (key, resource_detail[key]))
+        return '\n'.join(ret)
+
     def format_stack_summary(self, summaries):
         '''
         Return string formatted representation of
index 2a40f428db633e26a5a174903af0ebc9901f9d11..be7b9891dc15caed5e9067866b7f1140a4281000 100644 (file)
@@ -118,6 +118,9 @@ class V1Client(base_client.BaseClient):
     def format_stack_summary(self, summary):
         return str(summary)
 
+    def format_stack_resource_detail(self, res):
+        return str(res)
+
     def format_template(self, template):
         return str(template)