summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2016-09-14 20:15:28 -0400
committerZane Bitter <zbitter@redhat.com>2016-09-14 20:39:25 -0400
commitfbc0021cedfb7ff8748d8ddd5ad3b50cbfb312ef (patch)
treeaccc67cfb82e0b5e5ba76778e9d6823e9c12b5eb
parenta0b1916888dfdf585f41fa77f44567d46f673ad0 (diff)
downloadheat-fbc0021cedfb7ff8748d8ddd5ad3b50cbfb312ef.tar.gz
Make get_attr consistent across template versions
Several changes to when get_attr returns None as a placeholder were made to the original version of HOT but not reflected in later versions. The missing changes were: - I1b2b4f0e967695cf3297d93022cecec958e94b24 (The fix for bug 1333208.) - I6dbaa7ee4e9d534c31823b4812efcb387c695a22 (The implementation of the blueprint convergence-lightweight-stack. The lack of this suggests that our stacks may be less lightweight in practice than we thought.) - I2bfac4ce6a8806acc85c17466429d63a5d93d79f (A small change to the previous patch.) - I84762de87032168f97cdd19533649851073b4e81 (Part of the fix for bug 1486281) This change refactors the classes such that new and old versions of the templates share a single implementation of this test, so there should be no future opportunity for them to get out of sync. Change-Id: I367ba6abe5c0176ff84ec676a42e9329cf84b48e Closes-Bug: #1623707
-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 0b9e8277f..559203237 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