From: Steven Hardy Date: Wed, 15 Aug 2012 14:16:23 +0000 (+0100) Subject: heat cli : Workaround inconsistent boto return type X-Git-Tag: 2014.1~1532 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a9252c9b0583b61579c123d4c31b790d4d3ef07c;p=openstack-build%2Fheat-build.git heat cli : Workaround inconsistent boto return type 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 --- diff --git a/bin/heat b/bin/heat index fbfb3051..90dc28ba 100755 --- 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') diff --git a/heat/boto_client.py b/heat/boto_client.py index b296371d..7b5d84d0 100644 --- a/heat/boto_client.py +++ b/heat/boto_client.py @@ -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 diff --git a/heat/client.py b/heat/client.py index 2a40f428..be7b9891 100644 --- a/heat/client.py +++ b/heat/client.py @@ -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)