Fix nested template genearation when attribute path is not string
When determining attributes to cache, we seem to be assuming the
paths to be strings. If there are resource references in outputs
it would be None during validation.
As we've the same code snippet in all group resources
ex. ResourceGroup, ResourceChain and heat AutoScalingGroup, this
fixes it in all those places.
Change-Id: I36d623b183d01632041113f7bff63bf255f5d53c
Closes-Bug: #1719603
(cherry picked from commit aabb3392b3
)
This commit is contained in:
parent
dc42b8f483
commit
27426e8330
|
@ -226,7 +226,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||
output_name = attr
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
output_name = ', '.join(attr)
|
||||
output_name = ', '.join(six.text_type(a) for a in attr)
|
||||
|
||||
if key.startswith("resource."):
|
||||
keycomponents = key.split('.', 2)
|
||||
|
|
|
@ -166,7 +166,7 @@ class ResourceChain(stack_resource.StackResource):
|
|||
output_name = attr
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
output_name = ', '.join(attr)
|
||||
output_name = ', '.join(six.text_type(a) for a in attr)
|
||||
|
||||
if key.startswith("resource."):
|
||||
keycomponents = key.split('.', 2)
|
||||
|
|
|
@ -462,7 +462,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
output_name = attr
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
output_name = ', '.join(attr)
|
||||
output_name = ', '.join(six.text_type(a) for a in attr)
|
||||
|
||||
if key.startswith("resource."):
|
||||
keycomponents = key.split('.', 2)
|
||||
|
|
|
@ -42,6 +42,13 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
|
|||
self.assertRaises(exception.StackValidationFailed,
|
||||
stack['my-group'].validate)
|
||||
|
||||
def test_validate_reference_attr_with_none_ref(self):
|
||||
stack = utils.parse_stack(self.parsed)
|
||||
group = stack['my-group']
|
||||
self.patchobject(group, 'referenced_attrs',
|
||||
return_value=set([('something', None)]))
|
||||
self.assertIsNone(group.validate())
|
||||
|
||||
|
||||
class TestScalingGroupTags(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -129,6 +129,12 @@ class ResourceChainTest(common.HeatTestCase):
|
|||
chain = self._create_chain(TEMPLATE)
|
||||
chain.validate_nested_stack()
|
||||
|
||||
def test_validate_reference_attr_with_none_ref(self):
|
||||
chain = self._create_chain(TEMPLATE)
|
||||
self.patchobject(chain, 'referenced_attrs',
|
||||
return_value=set([('config', None)]))
|
||||
self.assertIsNone(chain.validate())
|
||||
|
||||
def test_validate_incompatible_properties(self):
|
||||
# Tests a resource in the chain that does not support the properties
|
||||
# specified to each resource.
|
||||
|
|
|
@ -507,6 +507,14 @@ class ResourceGroupTest(common.HeatTestCase):
|
|||
resgrp = resource_group.ResourceGroup('test', snip, stack)
|
||||
self.assertIsNone(resgrp.validate())
|
||||
|
||||
def test_validate_reference_attr_with_none_ref(self):
|
||||
stack = utils.parse_stack(template_attr)
|
||||
snip = stack.t.resource_definitions(stack)['group1']
|
||||
resgrp = resource_group.ResourceGroup('test', snip, stack)
|
||||
self.patchobject(resgrp, 'referenced_attrs',
|
||||
return_value=set([('nested_dict', None)]))
|
||||
self.assertIsNone(resgrp.validate())
|
||||
|
||||
def test_invalid_removal_policies_nolist(self):
|
||||
"""Test that error raised for malformed removal_policies."""
|
||||
tmp = copy.deepcopy(template)
|
||||
|
|
Loading…
Reference in New Issue