Display yaml format for stack deployed via hot template
Determine hot template and display yaml format for it, display json format for others. Change-Id: Ie8d72c222a992ee0048897d040e8bc88fcf51760 Fixes: bug #1201482
This commit is contained in:
parent
b417688d21
commit
e14758686f
@ -304,6 +304,59 @@ class ShellTest(TestCase):
|
||||
for r in required:
|
||||
self.assertRegexpMatches(list_text, r)
|
||||
|
||||
def test_template_show_cfn(self):
|
||||
fakes.script_keystone_client()
|
||||
template_data = open(os.path.join(TEST_VAR_DIR,
|
||||
'minimal.template')).read()
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
200,
|
||||
'OK',
|
||||
{'content-type': 'application/json'},
|
||||
template_data)
|
||||
resp_dict = json.loads(template_data)
|
||||
v1client.Client.json_request(
|
||||
'GET', '/stacks/teststack/template').AndReturn((resp, resp_dict))
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
show_text = self.shell('template-show teststack')
|
||||
required = [
|
||||
'{',
|
||||
' "AWSTemplateFormatVersion": "2010-09-09",',
|
||||
' "Outputs": {},',
|
||||
' "Resources": {},',
|
||||
' "Parameters": {}',
|
||||
'}'
|
||||
]
|
||||
for r in required:
|
||||
self.assertRegexpMatches(show_text, r)
|
||||
|
||||
def test_template_show_hot(self):
|
||||
fakes.script_keystone_client()
|
||||
resp_dict = {"heat_template_version": "2013-05-23",
|
||||
"parameters": {},
|
||||
"resources": {},
|
||||
"outputs": {}}
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
200,
|
||||
'OK',
|
||||
{'content-type': 'application/json'},
|
||||
json.dumps(resp_dict))
|
||||
v1client.Client.json_request(
|
||||
'GET', '/stacks/teststack/template').AndReturn((resp, resp_dict))
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
show_text = self.shell('template-show teststack')
|
||||
required = [
|
||||
"heat_template_version: '2013-05-23'",
|
||||
"outputs: {}",
|
||||
"parameters: {}",
|
||||
"resources: {}"
|
||||
]
|
||||
for r in required:
|
||||
self.assertRegexpMatches(show_text, r)
|
||||
|
||||
def test_create(self):
|
||||
fakes.script_keystone_client()
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
|
@ -282,7 +282,10 @@ def do_template_show(hc, args):
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Stack not found: %s' % args.id)
|
||||
else:
|
||||
print json.dumps(template, indent=2)
|
||||
if 'heat_template_version' in template:
|
||||
print yaml.safe_dump(template, indent=2)
|
||||
else:
|
||||
print json.dumps(template, indent=2)
|
||||
|
||||
|
||||
@utils.arg('-u', '--template-url', metavar='<URL>',
|
||||
|
Loading…
Reference in New Issue
Block a user