summaryrefslogtreecommitdiff
path: root/heat/engine/hot
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2014-07-11 15:17:59 -0400
committerZane Bitter <zbitter@redhat.com>2014-07-29 21:09:01 -0400
commiteca6faa83e13a43546f7533b52e0fd3071fd97d4 (patch)
treebafd3974573974e8a40c3a6c55cc50d138b5d631 /heat/engine/hot
parent3d89c8b55b6bc2bd2919a75183dda03099d04830 (diff)
downloadheat-eca6faa83e13a43546f7533b52e0fd3071fd97d4.tar.gz
Allow Resources to select paths from attributes
Previously when get_attr included a path to select from the attribute, the selection was done by the get_attr intrinsic function. Starting with the Juno version of HOT, move control of this to the resource plugin, so that individual resources (particularly ResourceGroup) can handle it themselves. Related-Bug: #1341048 Change-Id: Ic3dc94a99a19e28a4f775198ff6e960e2efb8256
Diffstat (limited to 'heat/engine/hot')
-rw-r--r--heat/engine/hot/functions.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py
index 84bd05aab..23c333bb7 100644
--- a/heat/engine/hot/functions.py
+++ b/heat/engine/hot/functions.py
@@ -83,7 +83,7 @@ class GetParam(function.Function):
return ''
-class GetAtt(cfn_funcs.GetAtt):
+class GetAttThenSelect(cfn_funcs.GetAtt):
'''
A function for resolving resource attributes.
@@ -112,7 +112,7 @@ class GetAtt(cfn_funcs.GetAtt):
return tuple(self.args[:2])
def result(self):
- attribute = super(GetAtt, self).result()
+ attribute = super(GetAttThenSelect, self).result()
if attribute is None:
return None
@@ -120,6 +120,32 @@ class GetAtt(cfn_funcs.GetAtt):
return attributes.select_from_attribute(attribute, path_components)
+class GetAtt(GetAttThenSelect):
+ '''
+ A function for resolving resource attributes.
+
+ Takes the form::
+
+ get_attr:
+ - <resource_name>
+ - <attribute_name>
+ - <path1>
+ - ...
+ '''
+
+ def result(self):
+ 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)):
+ return r.FnGetAtt(attribute, *path_components)
+ else:
+ return None
+
+
class Replace(cfn_funcs.Replace):
'''
A function for performing string substitutions.
@@ -247,7 +273,7 @@ def function_mapping(version_key, version):
'get_param': GetParam,
'get_resource': cfn_funcs.ResourceRef,
'Ref': cfn_funcs.Ref,
- 'get_attr': GetAtt,
+ 'get_attr': GetAttThenSelect,
'Fn::Select': cfn_funcs.Select,
'Fn::Join': cfn_funcs.Join,
'Fn::Split': cfn_funcs.Split,