From f8ef790e96e99deedf2a1a5241c460d585778ba5 Mon Sep 17 00:00:00 2001 From: ricolin Date: Wed, 8 Apr 2020 16:59:43 +0800 Subject: [PATCH] Use resource_id instead of phy rsrc name in InstanceGroup Use default resource implementation for get_reference_id in: * OS::Heat::InstanceGroup * OS::Heat::AutoScalingGroup * AWS::AutoScaling::AutoScalingGroup Story: #2007007 Task: #37870 Change-Id: I7fd223a3bde1c5d2ecd073124a25675567e406d2 --- heat/engine/resources/openstack/heat/autoscaling_group.py | 4 ---- heat/engine/resources/openstack/heat/instance_group.py | 3 --- heat/tests/openstack/heat/test_instance_group.py | 6 +----- .../fix-autoscalinggroup-reference-id-caf8b80c9288ad0f.yaml | 5 +++-- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/heat/engine/resources/openstack/heat/autoscaling_group.py b/heat/engine/resources/openstack/heat/autoscaling_group.py index e288fe20f7..ed48bebf3f 100644 --- a/heat/engine/resources/openstack/heat/autoscaling_group.py +++ b/heat/engine/resources/openstack/heat/autoscaling_group.py @@ -23,7 +23,6 @@ from heat.engine import constraints from heat.engine.hot import template from heat.engine import output from heat.engine import properties -from heat.engine import resource from heat.engine.resources.aws.autoscaling import autoscaling_group as aws_asg from heat.engine import rsrc_defn from heat.engine import support @@ -208,9 +207,6 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup): self)._create_template(num_instances, num_replace, template_version=template_version) - def get_reference_id(self): - return resource.Resource.get_reference_id(self) - def _attribute_output_name(self, *attr_path): return ', '.join(six.text_type(a) for a in attr_path) diff --git a/heat/engine/resources/openstack/heat/instance_group.py b/heat/engine/resources/openstack/heat/instance_group.py index 103737d440..9ef901cb0c 100644 --- a/heat/engine/resources/openstack/heat/instance_group.py +++ b/heat/engine/resources/openstack/heat/instance_group.py @@ -422,9 +422,6 @@ class InstanceGroup(stack_resource.StackResource): lbs = [self.stack[name] for name in lb_names] lbutils.reconfigure_loadbalancers(lbs, id_list) - def get_reference_id(self): - return self.physical_resource_name_or_FnGetRefId() - def _group_data(self, refresh=False): """Return a cached GroupInspector object for the nested stack.""" if refresh or getattr(self, '_group_inspector', None) is None: diff --git a/heat/tests/openstack/heat/test_instance_group.py b/heat/tests/openstack/heat/test_instance_group.py index c13214c8e5..858c1488c3 100644 --- a/heat/tests/openstack/heat/test_instance_group.py +++ b/heat/tests/openstack/heat/test_instance_group.py @@ -18,7 +18,6 @@ import six from heat.common import exception from heat.common import grouputils -from heat.common import short_id from heat.common import template_format from heat.engine.clients.os import neutron from heat.engine import resource @@ -173,12 +172,9 @@ class TestInstanceGroup(common.HeatTestCase): def test_instance_group_refid_rsrc_name(self): self.instance_group.id = '123' - self.instance_group.uuid = '9bfb9456-3fe8-41f4-b318-9dba18eeef74' self.instance_group.action = 'CREATE' - expected = '%s-%s-%s' % (self.instance_group.stack.name, - self.instance_group.name, - short_id.get_id(self.instance_group.uuid)) + expected = self.instance_group.name self.assertEqual(expected, self.instance_group.FnGetRefId()) def test_instance_group_refid_rsrc_id(self): diff --git a/releasenotes/notes/fix-autoscalinggroup-reference-id-caf8b80c9288ad0f.yaml b/releasenotes/notes/fix-autoscalinggroup-reference-id-caf8b80c9288ad0f.yaml index 333c42ad6a..1021aa5283 100644 --- a/releasenotes/notes/fix-autoscalinggroup-reference-id-caf8b80c9288ad0f.yaml +++ b/releasenotes/notes/fix-autoscalinggroup-reference-id-caf8b80c9288ad0f.yaml @@ -1,9 +1,10 @@ --- fixes: - | - The behavior of ``get_resource`` on an ``OS::Heat::AutoScalingGroup`` + The behavior of ``get_resource`` on an ``OS::Heat::InstanceGroup`` resource has changed. Previously it returned the physical resource name (i.e. the name of the nested Heat stack which implemented the group). It will now return the UUID of the nested stack if available. This will also apply to any resource type that inherits from - ``OS::Heat::AutoScalingGroup``. + ``OS::Heat::AutoScalingGroup``, ``OS::Heat::InstanceGroup``, and + ``AWS::AutoScaling::AutoScalingGroup``.