From 9ad94efb3a8b5d65333e1d54352ce70c2cecd535 Mon Sep 17 00:00:00 2001 From: Thomas Spatzier Date: Mon, 12 Aug 2013 18:10:48 +0200 Subject: [PATCH] Adding HOT str_replace and get_resource functions This patch adds support for two functions, get_resource and str_replace to HOT to enable the definition of new HOT samples. Especially str_replace aims to simplify the definition of scripts in HOT templates. Change-Id: Ic14fee36bdc0b9c5d79ade7ece5fa1b5331c864a --- doc/source/template_guide/hot_spec.rst | 92 ++++++++++++++++++++++++++ heat/engine/hot.py | 55 +++++++++++++++ heat/tests/test_hot.py | 88 ++++++++++++++++++++++++ 3 files changed, 235 insertions(+) diff --git a/doc/source/template_guide/hot_spec.rst b/doc/source/template_guide/hot_spec.rst index 31219c36..aa6bea20 100644 --- a/doc/source/template_guide/hot_spec.rst +++ b/doc/source/template_guide/hot_spec.rst @@ -442,3 +442,95 @@ An example of using the get_attr function is shown below: outputs: instance_ip: { get_attr: [my_instance, PublicIp] } + + +get_resource +------------ +The *get_resource* function allows for referencing another resource within the +same template. At runtime, it will be resolved to reference ID of the resource, +which is resource type specific. For example, a reference to a floating IP +resource will return the respective IP address at runtime. +The syntax of the get_resource function is as follows: + +:: + + get_resource: + +The *resource ID* of the referenced resources as used in the current template is +given as single parameter to the get_resource function. + + +str_replace +----------- +The *str_replace* function allows for dynamically constructing strings by +providing a template string with placeholders and a list of mappings to assign +values to those placeholders at runtime. The functionality of this function is +similar to that of Python Template strings. +The syntax of the str_replace function is as follows: + +:: + + str_replace: + template: