From a9252c9b0583b61579c123d4c31b790d4d3ef07c Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 15 Aug 2012 15:16:23 +0100 Subject: [PATCH] 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 --- bin/heat | 2 +- heat/boto_client.py | 19 +++++++++++++++++++ heat/client.py | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/heat b/bin/heat index fbfb305130..90dc28ba45 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 b296371d07..7b5d84d03d 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 2a40f428db..be7b9891dc 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)