Make AutoScale sub-template a string instead of map

To avoid the InvalidTemplateReference exception when resolving
get_resource functions for resources that are in the sub-template but
not the parent template.

Change-Id: I985b58ff95efbc7926cec708d2b37d8ce95c3390
This commit is contained in:
Jason Dunsmore 2016-02-18 10:38:38 -06:00
parent 834ac4a041
commit c202c4447b
2 changed files with 75 additions and 73 deletions

View File

@ -18,6 +18,7 @@ import six
from heat.common import exception
from heat.common.i18n import _
from heat.common import template_format
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
@ -243,7 +244,7 @@ class Group(resource.Resource):
'directly passed to Heat when creating a stack.'),
schema={
LAUNCH_CONFIG_ARGS_STACK_TEMPLATE: properties.Schema(
properties.Schema.MAP,
properties.Schema.STRING,
_('The template that describes the stack. Either the '
'template or template_url property must be specified.'),
),
@ -533,7 +534,8 @@ class Group(resource.Resource):
if st_tmpl:
st_files = st_args.get(self.LAUNCH_CONFIG_ARGS_STACK_FILES)
try:
templatem.Template(st_tmpl, files=st_files, env=st_env)
tmpl = template_format.simple_parse(st_tmpl)
templatem.Template(tmpl, files=st_files, env=st_env)
except Exception as exc:
msg = (_('Encountered error while loading template: %s') %
six.text_type(exc))

View File

@ -232,7 +232,7 @@ class ScalingGroupTest(common.HeatTestCase):
type: launch_stack
args:
stack:
template:
template: |
heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
@ -336,20 +336,20 @@ class ScalingGroupTest(common.HeatTestCase):
'group_metadata': {'group': 'metadata'},
'name': 'My Group',
'launch_config_type': u'launch_stack',
'template': {
'heat_template_version': '2015-10-15',
'description': 'This is a Heat template',
'parameters': {
'flavor': {
'default': 'm1.tiny',
'type': 'string'},
'image': {
'default': 'cirros-0.3.4-x86_64-uec',
'type': 'string'}},
'resources': {
'rand': {'type': u'OS::Heat::RandomString'}
}
},
'template': (
'''heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
image:
default: cirros-0.3.4-x86_64-uec
type: string
flavor:
default: m1.tiny
type: string
resources:
rand:
type: OS::Heat::RandomString
'''),
'template_url': None,
'disable_rollback': False,
'environment': {
@ -931,20 +931,20 @@ class AutoScaleGroupValidationTests(common.HeatTestCase):
"type": "launch_stack",
"args": {
"stack": {
'template': {
'heat_template_version': '2015-10-15',
'description': 'This is a Heat template',
'parameters': {
'flavor': {
'default': 'm1.tiny',
'type': 'string'},
'image': {
'default': 'cirros-0.3.4-x86_64-uec',
'type': 'string'}},
'resources': {
'rand': {'type': u'OS::Heat::RandomString'}
}
},
'template': (
'''heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
image:
default: cirros-0.3.4-x86_64-uec
type: string
flavor:
default: m1.tiny
type: string
resources:
rand:
type: OS::Heat::RandomString
'''),
'template_url': None,
'disable_rollback': False,
'environment': {
@ -995,20 +995,20 @@ class AutoScaleGroupValidationTests(common.HeatTestCase):
"imageRef": "image-ref",
},
"stack": {
'template': {
'heat_template_version': '2015-10-15',
'description': 'This is a Heat template',
'parameters': {
'flavor': {
'default': 'm1.tiny',
'type': 'string'},
'image': {
'default': 'cirros-0.3.4-x86_64-uec',
'type': 'string'}},
'resources': {
'rand': {'type': u'OS::Heat::RandomString'}
}
},
'template': (
'''heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
image:
default: cirros-0.3.4-x86_64-uec
type: string
flavor:
default: m1.tiny
type: string
resources:
rand:
type: OS::Heat::RandomString
'''),
'template_url': None,
'disable_rollback': False,
'environment': {
@ -1086,20 +1086,20 @@ class AutoScaleGroupValidationTests(common.HeatTestCase):
"type": "launch_server",
"args": {
"stack": {
'template': {
'heat_template_version': '2015-10-15',
'description': 'This is a Heat template',
'parameters': {
'flavor': {
'default': 'm1.tiny',
'type': 'string'},
'image': {
'default': 'cirros-0.3.4-x86_64-uec',
'type': 'string'}},
'resources': {
'rand': {'type': 'OS::Heat::RandomString'}
}
},
'template': (
'''heat_template_version: 2015-10-15
description: This is a Heat template
parameters:
image:
default: cirros-0.3.4-x86_64-uec
type: string
flavor:
default: m1.tiny
type: string
resources:
rand:
type: OS::Heat::RandomString
'''),
'template_url': 'https://myhost.com/template.yaml',
}
}
@ -1179,20 +1179,20 @@ class AutoScaleGroupValidationTests(common.HeatTestCase):
"type": "launch_stack",
"args": {
"stack": {
'template': {
'SJDADKJAJKLSheat_template_version': '2015-10-15',
'description': 'This is a Heat template',
'parameters': {
'flavor': {
'default': 'm1.tiny',
'type': 'string'},
'image': {
'default': 'cirros-0.3.4-x86_64-uec',
'type': 'string'}},
'resources': {
'rand': {'type': u'OS::Heat::RandomString'}
}
},
'template': (
'''SJDADKJAJKLSheat_template_version: 2015-10-15
description: This is a Heat template
parameters:
image:
default: cirros-0.3.4-x86_64-uec
type: string
flavor:
default: m1.tiny
type: string
resources:
rand:
type: OS::Heat::RandomString
'''),
'template_url': None,
'disable_rollback': False,
'environment': {'Foo': 'Bar'},