summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-15 13:26:37 +0000
committerGerrit Code Review <review@openstack.org>2016-09-15 13:26:37 +0000
commit5dc1084260c8a7a7f5ec97d0cdfc1fc08cd8f82e (patch)
tree721624bf4dfed10a1bb3ca93fabbb7091d7d5c8d
parentd899c240e49a72246926b46f40f8076159bb5196 (diff)
parentfbc0021cedfb7ff8748d8ddd5ad3b50cbfb312ef (diff)
downloadheat-stable/newton.tar.gz
Merge "Make get_attr consistent across template versions"7.0.0.0rc1stable/newton
-rw-r--r--heat/engine/hot/functions.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py
index d3b7cc1f5..ddc477e92 100644
--- a/heat/engine/hot/functions.py
+++ b/heat/engine/hot/functions.py
@@ -212,17 +212,24 @@ class GetAttThenSelect(function.Function):
raise exception.InvalidTemplateAttribute(
resource=self._resource_name, key=attr)
- def result(self):
- attr_name = function.resolve(self._attribute)
-
- r = self._resource()
+ def _result_ready(self, r):
if r.action in (r.CREATE, r.ADOPT, r.SUSPEND, r.RESUME,
r.UPDATE, r.ROLLBACK, r.SNAPSHOT, r.CHECK):
- attribute = r.FnGetAtt(attr_name)
+ return True
+
# NOTE(sirushtim): Add r.INIT to states above once convergence
# is the default.
- elif r.stack.has_cache_data(r.name) and r.action == r.INIT:
- attribute = r.FnGetAtt(attr_name)
+ if r.stack.has_cache_data(r.name) and r.action == r.INIT:
+ return True
+
+ return False
+
+ def result(self):
+ attr_name = function.resolve(self._attribute)
+
+ resource = self._resource()
+ if self._result_ready(resource):
+ attribute = resource.FnGetAtt(attr_name)
else:
attribute = None
@@ -249,11 +256,9 @@ class GetAtt(GetAttThenSelect):
path_components = function.resolve(self._path_components)
attribute = function.resolve(self._attribute)
- r = self._resource()
- if (r.status in (r.IN_PROGRESS, r.COMPLETE) and
- r.action in (r.CREATE, r.ADOPT, r.SUSPEND, r.RESUME,
- r.UPDATE, r.CHECK, r.SNAPSHOT)):
- return r.FnGetAtt(attribute, *path_components)
+ resource = self._resource()
+ if self._result_ready(resource):
+ return resource.FnGetAtt(attribute, *path_components)
else:
return None