diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-01-21 22:00:51 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-01-21 22:00:51 +0000 |
commit | 068f3a68e899805f91c429df49260e8a1e516a42 (patch) | |
tree | de65ffae7b55bce112c126327bc5efbdb6f2aacc /heatclient/v1 | |
parent | 3636202f4bcd605c36bd16946fbcc970dcab6916 (diff) | |
parent | 43caa308d91080abcf3bdafe8836005e76863f44 (diff) | |
download | python-heatclient-068f3a68e899805f91c429df49260e8a1e516a42.tar.gz |
Merge "Use template_format.parse for local stack parsing"
Diffstat (limited to 'heatclient/v1')
-rw-r--r-- | heatclient/v1/shell.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 87dca4f..5c0774b 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -17,6 +17,7 @@ import os import urllib import yaml +from heatclient.common import template_format from heatclient.common import utils from heatclient.openstack.common import jsonutils from heatclient.openstack.common.py3kcompat import urlutils @@ -27,31 +28,33 @@ import heatclient.exc as exc def _set_template_fields(hc, args, fields): if args.template_file: tpl = open(args.template_file).read() - if tpl.startswith('{'): - try: - fields['template'] = jsonutils.loads(tpl) - except ValueError as e: - raise exc.CommandError( - "Cannot parse template file: %s" % e) - else: - fields['template'] = tpl - elif args.template_url: + try: + fields['template'] = template_format.parse(tpl) + except ValueError as e: + raise exc.CommandError( + "Cannot parse template file: %s" % e) + return args.template_file + + if args.template_url: fields['template_url'] = args.template_url - elif args.template_object: + return args.template_url + + if args.template_object: template_body = hc.http_client.raw_request('GET', args.template_object) if template_body: try: - fields['template'] = jsonutils.loads(template_body) + fields['template'] = template_format.parse(template_body) except ValueError as e: raise exc.CommandError( "Cannot parse template file: %s" % e) else: raise exc.CommandError('Could not fetch template from %s' % args.template_object) - else: - raise exc.CommandError('Need to specify exactly one of ' - '--template-file, --template-url ' - 'or --template-object') + return args.template_object + + raise exc.CommandError('Need to specify exactly one of ' + '--template-file, --template-url ' + 'or --template-object') def _get_file_contents(resource_registry, fields, base_url='', |