diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-01-11 16:43:38 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-01-11 16:43:38 +0000 |
commit | 62fb2583f2d8f69eb355fa47988be2b8770b4925 (patch) | |
tree | edcc4519ee5024381f769141dd4d13f32e206d15 | |
parent | a98eb4bab9253ead9d22be8678ba6b0ae788cc7a (diff) | |
parent | b06c3daeb78ce15b6a77ebfe75056d3ebed6a023 (diff) | |
download | python-heatclient-62fb2583f2d8f69eb355fa47988be2b8770b4925.tar.gz |
Merge "Added -P support to template-validate"
-rw-r--r-- | heatclient/tests/unit/test_shell.py | 36 | ||||
-rw-r--r-- | heatclient/v1/shell.py | 8 |
2 files changed, 43 insertions, 1 deletions
diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py index 908f4b7..7a94144 100644 --- a/heatclient/tests/unit/test_shell.py +++ b/heatclient/tests/unit/test_shell.py @@ -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() diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 1e8a69a..7be7621 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -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, } |