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 <shardy@redhat.com>
This commit is contained in:
Steven Hardy 2012-08-15 15:16:23 +01:00
parent 5aa80047b6
commit a9252c9b05
3 changed files with 23 additions and 1 deletions

View File

@ -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')

View 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

View 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)