openstack-manuals/doc/hot-reference/generated/functions.xml
Gauvain Pocentek fb109a27f4 Rebuild the hot-ref with new IDs
This patch uses the content generated with a new version of dn2osdbk.
All the docbook IDs have been changed, and are not prefixed with the
source file name. This should not be a problem since this guide has not
been officially released and is not linked from the docs index page.

Change-Id: Ie781bd340428bf1f56f7c4dcb80ea506de4ba8f3
2014-10-11 08:01:09 +02:00

371 lines
13 KiB
XML

<?xml version='1.0' encoding='UTF-8'?>
<!--Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.-->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="cloudformation-compatible-functions">
<!--WARNING: This file is automatically generated. Do not edit it.-->
<title>CloudFormation Compatible Functions</title>
<para>There are a number of functions that you can use to help you write
CloudFormation compatible templates.</para>
<para>All of these functions (except <emphasis>Ref</emphasis>) start with <emphasis>Fn::</emphasis>.</para>
<section xml:id="ref">
<?dbhtml stop-chunking?>
<title>Ref</title>
<para>Returns the value of the named parameter or resource.</para>
<section xml:id="parameters">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">name</term>
<listitem>
<para>The name of the resource or parameter.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="usage">
<title>Usage</title>
<programlisting>{Ref: my_server}</programlisting>
<para>Returns the nova instance ID. For example, <literal>d8093de0-850f-4513-b202-7979de6c0d55</literal>.</para>
</section>
</section>
<section xml:id="fn-base64">
<?dbhtml stop-chunking?>
<title>Fn::Base64</title>
<para>This returns the Base64 representation of the input string.</para>
<section xml:id="id1">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">value</term>
<listitem>
<para>The string to convert.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id2">
<title>Usage</title>
<programlisting>{Base64: "convert this string please."}</programlisting>
<para>Returns the Base64 of the input string.</para>
</section>
</section>
<section xml:id="fn-findinmap">
<?dbhtml stop-chunking?>
<title>Fn::FindInMap</title>
<para>Returns the value corresponding to keys into a two-level map declared in the
Mappings section.</para>
<section xml:id="id3">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">map_name</term>
<listitem>
<para>The logical name of a mapping declared in the Mappings section that
contains the keys and values.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="String">top_level_key</term>
<listitem>
<para>The top-level key name. It's value is a list of key-value pairs.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="String">second_level_key</term>
<listitem>
<para>The second-level key name, which is set to one of the keys from the list
assigned to top_level_key.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id4">
<title>Usage</title>
<programlisting>Mapping:
MyContacts:
jone: {phone: 337, email: a@b.com}
jim: {phone: 908, email: g@b.com}
{"Fn::FindInMap": ["MyContacts", "jim", "phone" ] }</programlisting>
<para>Returns <literal>908</literal>.</para>
</section>
</section>
<section xml:id="fn-getatt">
<?dbhtml stop-chunking?>
<title>Fn::GetAtt</title>
<para>Returns an attribute of a resource within the template.</para>
<section xml:id="id5">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">resource</term>
<listitem>
<para>The name of the resource.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="String">attribute</term>
<listitem>
<para>The name of the attribute.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id6">
<title>Usage</title>
<programlisting>{Fn::GetAtt: [my_server, PublicIp]}</programlisting>
<para>Returns an IP address such as <literal>10.0.0.2</literal>.</para>
</section>
</section>
<section xml:id="fn-getazs">
<?dbhtml stop-chunking?>
<title>Fn::GetAZs</title>
<para>Returns the Availability Zones within the given region.</para>
<para>
<emphasis>Note: AZ's and regions are not fully implemented in Heat.</emphasis>
</para>
<section xml:id="id7">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">region</term>
<listitem>
<para>The name of the region.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id8">
<title>Usage</title>
<programlisting>{Fn::GetAZs: ""}</programlisting>
<para>Returns the list provided by <literal>nova availability-zone-list</literal>.</para>
</section>
</section>
<section xml:id="fn-join">
<?dbhtml stop-chunking?>
<title>Fn::Join</title>
<para>Like python join, it joins a list of strings with the given delimiter.</para>
<section xml:id="id9">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">delimiter</term>
<listitem>
<para>The string to join the list with.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="list">list</term>
<listitem>
<para>The list to join.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id10">
<title>Usage</title>
<programlisting>{Fn::Join: [",", ["beer", "wine", "more beer"]]}</programlisting>
<para>Returns <literal>beer, wine, more beer</literal>.</para>
</section>
</section>
<section xml:id="fn-select">
<?dbhtml stop-chunking?>
<title>Fn::Select</title>
<para>Select an item from a list.</para>
<para>
<emphasis>Heat extension: Select an item from a map</emphasis>
</para>
<section xml:id="id11">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="string or integer">selector</term>
<listitem>
<para>The number of item in the list or the name of the item in the map.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="map or list">collection</term>
<listitem>
<para>The collection to select the item from.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id12">
<title>Usage</title>
<para>For a list lookup:</para>
<programlisting>{ "Fn::Select" : [ "2", [ "apples", "grapes", "mangoes" ] ] }</programlisting>
<para>Returns <literal>mangoes</literal>.</para>
<para>For a map lookup:</para>
<programlisting>{ "Fn::Select" : [ "red", {"red": "a", "flu": "b"} ] }</programlisting>
<para>Returns <literal>a</literal>.</para>
</section>
</section>
<section xml:id="fn-split">
<?dbhtml stop-chunking?>
<title>Fn::Split</title>
<para>This is the reverse of Join. Convert a string into a list based on the
delimiter.</para>
<section xml:id="id13">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="string">delimiter</term>
<listitem>
<para>Matching string to split on.</para>
</listitem>
</varlistentry>
<varlistentry>
<term role="String">string</term>
<listitem>
<para>The string to split.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id14">
<title>Usage</title>
<programlisting>{ "Fn::Split" : [ ",", "str1,str2,str3,str4"]}</programlisting>
<para>Returns <literal>{["str1", "str2", "str3", "str4"]}</literal>.</para>
</section>
</section>
<section xml:id="fn-replace">
<?dbhtml stop-chunking?>
<title>Fn::Replace</title>
<para>Find and replace one string with another.</para>
<section xml:id="id15">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="map">substitutions</term>
<listitem>
<para>A map of substitutions.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>string: String</term>
<listitem>
<para>The string to do the substitutions in.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id16">
<title>Usage</title>
<programlisting>{"Fn::Replace": [
{'$var1': 'foo', '%var2%': 'bar'},
'$var1 is %var2%'
]}</programlisting>
<para>Returns <literal>"foo is bar"</literal>.</para>
</section>
</section>
<section xml:id="fn-resourcefacade">
<?dbhtml stop-chunking?>
<title>Fn::ResourceFacade</title>
<variablelist role="definition_list">
<varlistentry>
<term>When writing a Template Resource:</term>
<listitem>
<itemizedlist>
<listitem>
<para>user writes a template that will fill in for a resource (the resource is the facade).</para>
</listitem>
<listitem>
<para>when they are writing their template they need to access the metadata from
the facade.</para>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
</variablelist>
<section xml:id="id17">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term role="String">attribute_name</term>
<listitem>
<para>One of <literal>Metadata</literal>, <literal>DeletionPolicy</literal> or <literal>UpdatePolicy</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id18">
<title>Usage</title>
<programlisting>{'Fn::ResourceFacade': 'Metadata'}
{'Fn::ResourceFacade': 'DeletionPolicy'}
{'Fn::ResourceFacade': 'UpdatePolicy'}</programlisting>
</section>
<section xml:id="example">
<title>Example</title>
<para>Here is a top level template <literal>top.yaml</literal></para>
<programlisting>resources:
my_server:
type: OS::Nova::Server
metadata:
key: value
some: more stuff</programlisting>
<para>Here is a resource template <literal>my_actual_server.yaml</literal></para>
<programlisting>resources:
_actual_server_:
type: OS::Nova::Server
metadata: {'Fn::ResourceFacade': Metadata}</programlisting>
<para>The environment file <literal>env.yaml</literal></para>
<programlisting>resource_registry:
resources:
my_server:
"OS::Nova::Server": my_actual_server.yaml</programlisting>
<para>To use it</para>
<programlisting>$ heat stack-create -f top.yaml -e env.yaml</programlisting>
<para>What happened is the metadata in <literal>top.yaml</literal> (key: value, some: more
stuff) gets passed into the resource template via the <link linkend="fn-resourcefacade">Fn::ResourceFacade</link>
function.</para>
</section>
</section>
<section xml:id="fn-memberlisttomap">
<?dbhtml stop-chunking?>
<title>Fn::MemberListToMap</title>
<para>Convert an AWS style member list into a map.</para>
<section xml:id="id19">
<title>Parameters</title>
<variablelist role="definition_list">
<varlistentry>
<term>key name: string</term>
<listitem>
<para>The name of the key (normally "Name" or "Key").</para>
</listitem>
</varlistentry>
<varlistentry>
<term>value name: string</term>
<listitem>
<para>The name of the value (normally "Value").</para>
</listitem>
</varlistentry>
<varlistentry>
<term>list: A list of strings</term>
<listitem>
<para>The string to convert.</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<section xml:id="id20">
<title>Usage</title>
<programlisting>{'Fn::MemberListToMap': ['Name', 'Value', ['.member.0.Name=key',
'.member.0.Value=door',
'.member.1.Name=colour',
'.member.1.Value=green']]}</programlisting>
<para>Returns <literal>{'key': 'door', 'colour': 'green'}</literal>.</para>
</section>
</section>
</chapter>