diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-09-15 13:26:37 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-09-15 13:26:37 +0000 |
commit | 5dc1084260c8a7a7f5ec97d0cdfc1fc08cd8f82e (patch) | |
tree | 721624bf4dfed10a1bb3ca93fabbb7091d7d5c8d | |
parent | d899c240e49a72246926b46f40f8076159bb5196 (diff) | |
parent | fbc0021cedfb7ff8748d8ddd5ad3b50cbfb312ef (diff) | |
download | heat-7.0.0.0rc1.tar.gz |
Merge "Make get_attr consistent across template versions"7.0.0.0rc1stable/newton
-rw-r--r-- | heat/engine/hot/functions.py | 29 |
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 |