diff --git a/heat/engine/service.py b/heat/engine/service.py index 57f039cd9c..7d372acf73 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -1273,6 +1273,14 @@ class EngineService(service.ServiceBase): 'Description', ''), 'Parameters': n_params } + + # Add parameter_groups if it is present in nested stack + nested_pg = parameter_groups.ParameterGroups( + stk[r].nested().t) + if nested_pg.parameter_groups: + n_result[r].update({'ParameterGroups': + nested_pg.parameter_groups}) + n_result[r].update(nested_params(stk[r].nested())) return {'NestedParameters': n_result} if n_result else {} diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 0fc53feb34..ea31e1bae8 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -19,6 +19,7 @@ import webob from heat.common import exception from heat.common.i18n import _ from heat.common import template_format +from heat.common import urlfetch from heat.engine.clients.os import glance from heat.engine.clients.os import nova from heat.engine import environment @@ -1746,3 +1747,67 @@ class ValidateTest(common.HeatTestCase): ex = webob.exc.HTTPBadRequest(explanation=msg) self.assertIsInstance(res, webob.exc.HTTPBadRequest) self.assertEqual(ex.explanation, res.explanation) + + def test_validate_parameter_group_output(self): + engine = service.EngineService('a', 't') + params = { + "resource_registry": { + "OS::Test::TestResource": "https://server.test/nested.template" + } + } + root_template_str = ''' +heat_template_version: 2015-10-15 +parameters: + test_root_param: + type: string +parameter_groups: +- label: RootTest + parameters: + - test_root_param +resources: + Nested: + type: OS::Test::TestResource +''' + nested_template_str = ''' +heat_template_version: 2015-10-15 +parameters: + test_param: + type: string +parameter_groups: +- label: Test + parameters: + - test_param +''' + root_template = template_format.parse(root_template_str) + + self.patchobject(urlfetch, 'get') + urlfetch.get.return_value = nested_template_str + + res = dict(engine.validate_template(self.ctx, root_template, + params, show_nested=True)) + expected = { + 'Description': 'No description', + 'ParameterGroups': [{ + 'label': 'RootTest', + 'parameters': ['test_root_param']}], + 'Parameters': { + 'test_root_param': { + 'Description': '', + 'Label': 'test_root_param', + 'NoEcho': 'false', + 'Type': 'String'}}, + 'NestedParameters': { + 'Nested': { + 'Description': 'No description', + 'ParameterGroups': [{ + 'label': 'Test', + 'parameters': ['test_param']}], + 'Parameters': { + 'test_param': { + 'Description': '', + 'Label': 'test_param', + 'NoEcho': 'false', + 'Type': 'String'}}, + 'Type': 'OS::Test::TestResource'}}, + } + self.assertEqual(expected, res) diff --git a/releasenotes/notes/parameter-group-for-nested-04559c4de34e326a.yaml b/releasenotes/notes/parameter-group-for-nested-04559c4de34e326a.yaml new file mode 100644 index 0000000000..852139cb5f --- /dev/null +++ b/releasenotes/notes/parameter-group-for-nested-04559c4de34e326a.yaml @@ -0,0 +1,4 @@ +--- +features: + - ParameterGroups section is added to the nested stacks, + for the output of the stack validate templates.