From b0506c933cf04ad4cfd1961a70ecc6049582a605 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 2 Feb 2017 13:43:35 -0500 Subject: [PATCH] Use stored value in OS::Heat::Value resource Currently when getting the 'value' attribute of an OS::Heat::Value resource, we recalculate the value from the properties - which means re-resolving any functions, including get_attr and the like. That's expensive and opens the possibility that the value can change over time, which is probably not what users would expect. Use the property values stored in the database at the time the resource was created or last updated instead. Change-Id: If0f80cab94c28514d1569b1025362ab9d9d31512 Closes-Bug: #1661728 --- heat/engine/resources/openstack/heat/value.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/heat/engine/resources/openstack/heat/value.py b/heat/engine/resources/openstack/heat/value.py index 2b2c6752b7..87786d885d 100644 --- a/heat/engine/resources/openstack/heat/value.py +++ b/heat/engine/resources/openstack/heat/value.py @@ -65,8 +65,10 @@ class Value(resource.Resource): } def _resolve_attribute(self, name): + props = self.frozen_definition().properties(self.properties_schema, + self.context) if name == self.VALUE_ATTR: - return self.properties[self.VALUE] + return props[self.VALUE] def handle_create(self): self.resource_id_set(self.physical_resource_name()) @@ -76,9 +78,9 @@ class Value(resource.Resource): # the resource properties are updated appropriately in parent class. pass - def __init__(self, name, definition, stack): - super(Value, self).__init__(name, definition, stack) - value_type = self.properties.get(self.TYPE) + def reparse(self, *args, **kwargs): + super(Value, self).reparse(*args, **kwargs) + value_type = self.properties[self.TYPE] if value_type is None: # We don't know what type the value is, anything goes return