Merge "Added -P support to template-validate"
This commit is contained in:
@@ -955,6 +955,42 @@ class ShellTestUserPass(ShellBase):
|
||||
for r in required:
|
||||
self.assertRegexpMatches(show_text, r)
|
||||
|
||||
def test_template_validate(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
resp_dict = {"heat_template_version": "2013-05-23",
|
||||
"parameters": {},
|
||||
"resources": {},
|
||||
"outputs": {}}
|
||||
resp = fakes.FakeHTTPResponse(
|
||||
200,
|
||||
'OK',
|
||||
{'content-type': 'application/json'},
|
||||
jsonutils.dumps(resp_dict))
|
||||
if self.client == http.SessionClient:
|
||||
self.client.request('/validate',
|
||||
'POST',
|
||||
data=mox.IgnoreArg()
|
||||
).AndReturn(resp)
|
||||
else:
|
||||
self.client.json_request('POST',
|
||||
'/validate',
|
||||
data=mox.IgnoreArg()
|
||||
).AndReturn((resp, resp_dict))
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||
cmd = 'template-validate -f %s -P foo=bar' % template_file
|
||||
show_text = self.shell(cmd)
|
||||
required = [
|
||||
'heat_template_version',
|
||||
'outputs',
|
||||
'parameters',
|
||||
'resources'
|
||||
]
|
||||
for r in required:
|
||||
self.assertRegexpMatches(show_text, r)
|
||||
|
||||
def _test_stack_preview(self, timeout=None, enable_rollback=False,
|
||||
tags=None):
|
||||
self.register_keystone_auth_fixture()
|
||||
|
||||
@@ -816,8 +816,13 @@ def do_template_show(hc, args):
|
||||
help=_('URL to retrieve template object (e.g. from swift).'))
|
||||
@utils.arg('-n', '--show-nested', default=False, action="store_true",
|
||||
help=_('Resolve parameters from nested templates as well.'))
|
||||
@utils.arg('-P', '--parameters', metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
|
||||
help=_('Parameter values for the template. '
|
||||
'This can be specified multiple times, or once with '
|
||||
'parameters separated by a semicolon.'),
|
||||
action='append')
|
||||
def do_template_validate(hc, args):
|
||||
'''Validate a template with parameters.'''
|
||||
"""Validate a template with parameters."""
|
||||
|
||||
tpl_files, template = template_utils.get_template_contents(
|
||||
args.template_file,
|
||||
@@ -829,6 +834,7 @@ def do_template_validate(hc, args):
|
||||
env_paths=args.environment_file)
|
||||
fields = {
|
||||
'template': template,
|
||||
'parameters': utils.format_parameters(args.parameters),
|
||||
'files': dict(list(tpl_files.items()) + list(env_files.items())),
|
||||
'environment': env,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user