Add ParameterGroups for the nested stack during stack.validate

ParameterGroups is added only for the parent stack and all
the nested stack are missing this information. Added
ParameterGroups for all the nested stack also, if present.

Change-Id: I032144733bde916f8de8644121b9fb1ef29baef2
This commit is contained in:
Saravanan KR 2017-05-11 14:19:07 +05:30
parent e8e0a2483a
commit b15b7e568c
3 changed files with 77 additions and 0 deletions

View File

@ -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 {}

View File

@ -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)

View File

@ -0,0 +1,4 @@
---
features:
- ParameterGroups section is added to the nested stacks,
for the output of the stack validate templates.