From 07382d99d1b4dcf5697c88e43b8f81f647965d3c Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Mon, 8 Jan 2018 17:23:12 -0500 Subject: [PATCH] Fix attribute caching in Heat AutoScalingGroup Attributes for an individual resource in an OS::Heat::AutoScalingGroup can be retrieved using the attribute name 'resource.'. Because we were treating the index as a resource name when generating the template, we would never generate an output in the nested template that referenced the resource's attribute, so it wouldn't get cached. Since we can't know the indices ahead of time, the only way to cache these is to do it for all resources in the group - which is the same data cached by the equivalent 'outputs' attribute. We also need to take into account both possible forms of syntax: [, resource.., ...] or: [, resource., , ...] Change-Id: I1d2898cdd4759b1bb9de1896a40056685e728f44 Closes-Bug: #1737047 Partial-Bug: #1731349 Related-Bug: #1660831 (cherry picked from commit 4a3a1ad15bdcfd67e0548481c70545e41a9476d9) --- .../resources/openstack/heat/autoscaling_group.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/heat/engine/resources/openstack/heat/autoscaling_group.py b/heat/engine/resources/openstack/heat/autoscaling_group.py index 5b31a240e9..54add09dc0 100644 --- a/heat/engine/resources/openstack/heat/autoscaling_group.py +++ b/heat/engine/resources/openstack/heat/autoscaling_group.py @@ -230,13 +230,12 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup): if key.startswith("resource."): keycomponents = key.split('.', 2) - res_name = keycomponents[1] - attr_name = keycomponents[2:] - if attr_name and (res_name in resource_names): - value = get_attr_fn([res_name] + attr_name + path) - yield output.OutputDefinition(output_name, value) + path = keycomponents[2:] + path + if path: + key = self.OUTPUTS + output_name = ', '.join([self.OUTPUTS] + path) - elif key == self.OUTPUTS and path: + if key == self.OUTPUTS and path: value = {r: get_attr_fn([r] + path) for r in resource_names} yield output.OutputDefinition(output_name, value)