~ubuntu-branches/ubuntu/wily/heat/wily

« back to all changes in this revision

Viewing changes to doc/source/template_guide/hot_spec.rst

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2015-08-19 08:11:50 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20150819081150-m969fd35xn8bdmfu
Tags: 1:5.0.0~b2-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* d/control: Align (build-)depends with upstream.
* d/p/fix-requirements.patch: Dropped. No longer needed.
* d/p/fixup-assert-regex.patch: Rebased.
* d/rules: Remove .eggs directory in override_dh_auto_clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. highlight: yaml
 
2
   :linenothreshold: 5
 
3
 
1
4
..
2
5
      Licensed under the Apache License, Version 2.0 (the "License"); you may
3
6
      not use this file except in compliance with the License. You may obtain
14
17
.. _hot_spec:
15
18
 
16
19
===============================================
17
 
Heat Orchestration Template (HOT) Specification
 
20
Heat Orchestration Template (HOT) specification
18
21
===============================================
19
22
 
20
 
HOT is a new template format meant to replace the Heat CloudFormation-compatible
21
 
format (CFN) as the native format supported by the Heat over time.
22
 
This specification explains in detail all elements of the HOT template format.
 
23
HOT is a new template format meant to replace the Heat
 
24
CloudFormation-compatible format (CFN) as the native format supported by the
 
25
Heat over time. This specification explains in detail all elements of the HOT
 
26
template format.
23
27
An example driven guide to writing HOT templates can be found
24
28
at :ref:`hot_guide`.
25
29
 
26
 
------
27
30
Status
28
 
------
 
31
~~~~~~
29
32
 
30
33
HOT is considered reliable, supported, and standardized as of our
31
34
Icehouse (April 2014) release.  The Heat core team may make improvements
33
36
format is also versioned.  Since Juno release, Heat supports multiple
34
37
different versions of the HOT specification.
35
38
 
36
 
------------------
37
 
Template Structure
38
 
------------------
 
39
Template structure
 
40
~~~~~~~~~~~~~~~~~~
39
41
 
40
42
HOT templates are defined in YAML and follow the structure outlined below.
41
43
 
59
61
    # declaration of output parameters
60
62
 
61
63
heat_template_version
62
 
    This key with value *2013-05-23* (or a later date) indicates that the YAML
63
 
    document is a HOT template of the specified version.
 
64
    This key with value ``2013-05-23`` (or a later date) indicates that the
 
65
    YAML document is a HOT template of the specified version.
64
66
 
65
67
description
66
 
    This *optional* key allows for giving a description of the template, or the
 
68
    This optional key allows for giving a description of the template, or the
67
69
    workload that can be deployed using the template.
68
70
 
69
71
parameter_groups
70
72
    This section allows for specifying how the input parameters should be
71
73
    grouped and the order to provide the parameters in. This section is
72
 
    *optional* and can be omitted when necessary.
 
74
    optional and can be omitted when necessary.
73
75
 
74
76
parameters
75
 
    This section allows for specifying input parameters that have to be provided
76
 
    when instantiating the template. The section is *optional* and can be
77
 
    omitted when no input is required.
 
77
    This section allows for specifying input parameters that have to be
 
78
    provided when instantiating the template. The section is optional and can
 
79
    be omitted when no input is required.
78
80
 
79
81
resources
80
82
    This section contains the declaration of the single resources of the
83
85
    instantiated.
84
86
 
85
87
outputs
86
 
    This section allows for specifying output parameters available to users once
87
 
    the template has been instantiated. This section is *optional* and can be
88
 
    omitted when no output values are required.
 
88
    This section allows for specifying output parameters available to users
 
89
    once the template has been instantiated. This section is optional and can
 
90
    be omitted when no output values are required.
89
91
 
90
92
 
91
93
.. _hot_spec_template_version:
92
94
 
93
 
---------------------
94
 
Heat Template Version
95
 
---------------------
 
95
Heat template version
 
96
~~~~~~~~~~~~~~~~~~~~~
96
97
 
97
 
The value of  *heat_template_version* tells Heat not only the format of the
 
98
The value of ``heat_template_version`` tells Heat not only the format of the
98
99
template but also features that will be validated and supported.
99
100
For example, Heat currently supports the following values for the
100
 
*heat_template_version* key:
 
101
``heat_template_version`` key:
101
102
 
102
103
2013-05-23
103
 
    The key with value *2013-05-23* indicates that the YAML document is a HOT
104
 
    template and it may contain features implemented until the Icehouse release.
105
 
    This version supports the following functions (some are back ported
106
 
    to this version):
 
104
    The key with value ``2013-05-23`` indicates that the YAML document is a HOT
 
105
    template and it may contain features implemented until the Icehouse
 
106
    release. This version supports the following functions (some are back
 
107
    ported to this version)::
107
108
 
108
 
::
109
 
  get_attr
110
 
  get_file
111
 
  get_param
112
 
  get_resource
113
 
  list_join
114
 
  resource_facade
115
 
  str_replace
116
 
  Fn::Base64
117
 
  Fn::GetAZs
118
 
  Fn::Join
119
 
  Fn::MemberListToMap
120
 
  Fn::Replace
121
 
  Fn::ResourceFacade
122
 
  Fn::Select
123
 
  Fn::Split
124
 
  Ref
 
109
      get_attr
 
110
      get_file
 
111
      get_param
 
112
      get_resource
 
113
      list_join
 
114
      resource_facade
 
115
      str_replace
 
116
      Fn::Base64
 
117
      Fn::GetAZs
 
118
      Fn::Join
 
119
      Fn::MemberListToMap
 
120
      Fn::Replace
 
121
      Fn::ResourceFacade
 
122
      Fn::Select
 
123
      Fn::Split
 
124
      Ref
125
125
 
126
126
2014-10-16
127
 
    The key with value *2014-10-16* indicates that the YAML document is a HOT
 
127
    The key with value ``2014-10-16`` indicates that the YAML document is a HOT
128
128
    template and it may contain features added and/or removed up until the Juno
129
129
    release.  This version removes most CFN functions that were supported in
130
 
    the Icehouse release, i.e. the *2013-05-23* version.  So the supported functions
131
 
    now are:
 
130
    the Icehouse release, i.e. the ``2013-05-23`` version.  So the supported
 
131
    functions now are::
132
132
 
133
 
::
134
 
  get_attr
135
 
  get_file
136
 
  get_param
137
 
  get_resource
138
 
  list_join
139
 
  resource_facade
140
 
  str_replace
141
 
  Fn::Select
 
133
      get_attr
 
134
      get_file
 
135
      get_param
 
136
      get_resource
 
137
      list_join
 
138
      resource_facade
 
139
      str_replace
 
140
      Fn::Select
142
141
 
143
142
2015-04-30
144
 
    The key with value *2015-04-30* indicates that the YAML document is a HOT
 
143
    The key with value ``2015-04-30`` indicates that the YAML document is a HOT
145
144
    template and it may contain features added and/or removed up until the Kilo
146
 
    release. This version adds the *repeat* function. So the complete list of
147
 
    supported functions is:
 
145
    release. This version adds the ``repeat`` function. So the complete list of
 
146
    supported functions is::
 
147
 
 
148
      get_attr
 
149
      get_file
 
150
      get_param
 
151
      get_resource
 
152
      list_join
 
153
      repeat
 
154
      digest
 
155
      resource_facade
 
156
      str_replace
 
157
      Fn::Select
 
158
 
 
159
2015-10-15
 
160
    The key with value ``2015-10-15`` indicates that the YAML document is a HOT
 
161
    template and it may contain features added and/or removed up until the
 
162
    Liberty release. This version removes the *Fn::Select* function, path based
 
163
    ``get_attr``/``get_param`` references should be used instead.
148
164
 
149
165
::
 
166
 
150
167
  get_attr
151
168
  get_file
152
169
  get_param
156
173
  digest
157
174
  resource_facade
158
175
  str_replace
159
 
  Fn::Select
160
 
 
 
176
  str_split
161
177
 
162
178
.. _hot_spec_parameter_groups:
163
179
 
164
 
------------------------
165
 
Parameter Groups Section
166
 
------------------------
 
180
Parameter groups section
 
181
~~~~~~~~~~~~~~~~~~~~~~~~
167
182
 
168
 
The *parameter_groups* section allows for specifying how the input parameters
 
183
The ``parameter_groups`` section allows for specifying how the input parameters
169
184
should be grouped and the order to provide the parameters in. These groups are
170
185
typically used to describe expected behavior for downstream user interfaces.
171
186
 
172
187
These groups are specified in a list with each group containing a list of
173
188
associated parameters. The lists are used to denote the expected order of the
174
189
parameters. Each parameter should be associated to a specific group only once
175
 
using the parameter name to bind it to a defined parameter in the parameters
176
 
section.
 
190
using the parameter name to bind it to a defined parameter in the
 
191
``parameters`` section.
177
192
 
178
193
::
179
194
 
195
210
    A list of parameters associated with this parameter group.
196
211
 
197
212
param name
198
 
    The name of the parameter that is defined in the associated parameters
 
213
    The name of the parameter that is defined in the associated ``parameters``
199
214
    section.
200
215
 
201
216
 
202
217
.. _hot_spec_parameters:
203
218
 
204
 
------------------
205
 
Parameters Section
206
 
------------------
 
219
Parameters section
 
220
~~~~~~~~~~~~~~~~~~
207
221
 
208
 
The *parameters* section allows for specifying input parameters that have to be
209
 
provided when instantiating the template. Such parameters are typically used to
210
 
customize each deployment (e.g. by setting custom user names or passwords) or
211
 
for binding to environment-specifics like certain images.
 
222
The ``parameters`` section allows for specifying input parameters that have to
 
223
be provided when instantiating the template. Such parameters are typically used
 
224
to customize each deployment (e.g. by setting custom user names or passwords)
 
225
or for binding to environment-specifics like certain images.
212
226
 
213
227
Each parameter is specified in a separated nested block with the name of the
214
228
parameters defined in the first line and additional attributes such as type or
227
241
        <parameter constraints>
228
242
 
229
243
param name
230
 
    The name of the parameter is defined at the top of each parameter block.
 
244
    The name of the parameter.
231
245
 
232
246
type
233
 
    This attribute specifies the type of parameter. Currently supported types
234
 
    are *string*, *number*, *comma_delimited_list*, *json*, or *boolean*.
 
247
    The type of the parameter. Supported types
 
248
    are ``string``, ``number``, ``comma_delimited_list``, ``json`` and
 
249
    ``boolean``.
 
250
    This attribute is required.
235
251
 
236
252
label
237
 
    This *optional* attribute allows for giving a human readable name of the
238
 
    parameter.
 
253
    A human readable name for the parameter.
 
254
    This attribute is optional.
239
255
 
240
256
description
241
 
    This *optional* attribute allows for giving a human readable description of
242
 
    the parameter.
 
257
    A human readable description for the parameter.
 
258
    This attribute is optional.
243
259
 
244
260
default
245
 
    This *optional* attribute allows for defining a default value for the
246
 
    parameters which will be used in case the parameter is not specified by the
247
 
    user during deployment.
 
261
    A default value for the parameter. This value is used if the user doesn't
 
262
    specify his own value during deployment.
 
263
    This attribute is optional.
248
264
 
249
265
hidden
250
 
    This *optional* attribute allows for specifying whether the parameters
251
 
    should be hidden when showing information about a stack created from the
252
 
    template at runtime (e.g. for hiding passwords that were specified as
253
 
    parameters). If not specified, the default value 'false' will be used.
 
266
    Defines whether the parameters should be hidden when a user requests
 
267
    information about a stack created from the template. This attribute can be
 
268
    used to hide passwords specified as parameters.
 
269
 
 
270
    This attribute is optional and defaults to ``false``.
254
271
 
255
272
constraints
256
 
    This *optional* block allows for specifying additional constraints on the
257
 
    parameter, such as minimum or maximum values for numeric parameters.
 
273
    A list of constraints to apply. The constraints are validated by the
 
274
    Orchestration engine when a user deploys a stack. The stack creation fails
 
275
    if the parameter value doesn't comply to the constraints.
 
276
    This attribute is optional.
258
277
 
259
278
The table below describes all currently supported types with examples:
260
279
 
281
300
|                      | false value.                  |                  |
282
301
+----------------------+-------------------------------+------------------+
283
302
 
284
 
The following example shows a minimalistic definition of two parameters. Note
285
 
that the description and label are actually optional, but is good practice to
286
 
provide a useful description and label for each parameter.
287
 
 
288
 
::
 
303
The following example shows a minimalistic definition of two parameters::
289
304
 
290
305
  parameters:
291
306
    user_name:
297
312
      label: Port Number
298
313
      description: Port number to be configured for the web server
299
314
 
 
315
.. note::
 
316
    The description and the label are optional, but defining these attributes
 
317
    is good practice to provide useful information about the role of the
 
318
    parameter to the user.
300
319
 
301
320
.. _hot_spec_parameters_constraints:
302
321
 
303
322
Parameter Constraints
304
323
---------------------
305
324
 
306
 
The *constraints* block of a parameter definition allows for defining additional
307
 
validation constraints that apply to the value of the parameter. At
308
 
instantiation time of the template, user provided parameter values are validated
309
 
against those constraints to make sure the provided values match expectations of
310
 
the template author.
311
 
Constraints are defined in the form of a bulleted list according to the
312
 
following syntax:
313
 
 
314
 
::
 
325
The ``constraints`` block of a parameter definition defines
 
326
additional validation constraints that apply to the value of the
 
327
parameter. The parameter values provided by a user are validated against the
 
328
constraints at instantiation time. The constraints are defined as a list with
 
329
the following syntax::
315
330
 
316
331
  constraints:
317
332
    - <constraint type>: <constraint definition>
318
333
      description: <constraint description>
319
334
 
320
335
constraint type
321
 
    The constraint type specifies the kind of constraint defined in the current
322
 
    bulleted list item. The set of currently supported constraints is given
323
 
    below.
 
336
    Type of constraint to apply. The set of currently supported constraints is
 
337
    given below.
324
338
 
325
339
constraint definition
326
 
    This value defines the actual constraint, depending on the constraint type.
327
 
    The concrete syntax for each constraint type is given below.
 
340
    The actual constraint, depending on the constraint type. The
 
341
    concrete syntax for each constraint type is given below.
328
342
 
329
343
description
330
 
    This *optional* attribute allows for specifying a concrete description of
331
 
    the current constraint. This text will be presented to the user, for
332
 
    example, when the provided input value for a parameter violates the
333
 
    constraint. If omitted, a default validation message will be presented to
334
 
    the user.
 
344
    A description of the constraint. The text
 
345
    is presented to the user when the value he defines violates the constraint.
 
346
    If omitted, a default validation message is presented to the user.
 
347
    This attribute is optional.
335
348
 
336
 
The following example show the definition of a string parameter with two
 
349
The following example shows the definition of a string parameter with two
337
350
constraints. Note that while the descriptions for each constraint are optional,
338
 
it is good practice to provide concrete descriptions so useful messages can be
339
 
presented to the user at deployment time.
 
351
it is good practice to provide concrete descriptions to present useful messages
 
352
to the user at deployment time.
340
353
 
341
354
::
342
355
 
351
364
        - allowed_pattern: "[A-Z]+[a-zA-Z0-9]*"
352
365
          description: User name must start with an uppercase character
353
366
 
 
367
.. note::
 
368
   While the descriptions for each constraint are optional, it is good practice
 
369
   to provide concrete descriptions so useful messages can be presented to the
 
370
   user at deployment time.
 
371
 
354
372
The following sections list the supported types of parameter constraints, along
355
373
with the concrete syntax for each type.
356
374
 
357
375
length
358
 
~~~~~~
359
 
The *length* constraint applies to parameters of type *string* and allows for
360
 
defining a lower and upper limit for the length of the string value. The syntax
361
 
for the length constraint is:
362
 
 
363
 
::
364
 
 
365
 
  length: { min: <lower limit>, max: <upper limit> }
 
376
++++++
 
377
The ``length`` constraint applies to parameters of type
 
378
``string``. It defines a lower and upper limit for the length of the
 
379
string value.
 
380
 
 
381
The syntax of the ``length`` constraint is::
 
382
 
 
383
   length: { min: <lower limit>, max: <upper limit> }
366
384
 
367
385
It is possible to define a length constraint with only a lower limit or an
368
 
upper limit. However, at least one of *min* or *max* must be specified.
 
386
upper limit. However, at least one of ``min`` or ``max`` must be specified.
369
387
 
370
388
range
371
 
~~~~~
372
 
The *range* constraint applies to parameters of type *number* and allows for
373
 
defining a lower and upper limit for the numeric value of the parameter. The
374
 
syntax of the range constraint is:
375
 
 
376
 
::
377
 
 
378
 
  range: { min: <lower limit>, max: <upper limit> }
 
389
+++++
 
390
The ``range`` constraint applies to parameters of type ``number``.
 
391
It defines a lower and upper limit for the numeric value of the
 
392
parameter.
 
393
 
 
394
The syntax of the ``range`` constraint is::
 
395
 
 
396
   range: { min: <lower limit>, max: <upper limit> }
379
397
 
380
398
It is possible to define a range constraint with only a lower limit or an
381
 
upper limit. However, at least one of *min* or *max* must be specified.
382
 
The minimum or maximum boundaries are included in the range. For example, the
383
 
following range constraint would allow for all numeric values between 0 and 10.
384
 
 
385
 
::
386
 
 
387
 
  range: { min: 0, max: 10 }
 
399
upper limit. However, at least one of ``min`` or ``max`` must be specified.
 
400
 
 
401
The minimum and maximum boundaries are included in the range. For example, the
 
402
following range constraint would allow for all numeric values between 0 and
 
403
10::
 
404
 
 
405
   range: { min: 0, max: 10 }
388
406
 
389
407
 
390
408
allowed_values
391
 
~~~~~~~~~~~~~~
392
 
The *allowed_values* constraint applies to parameters of type string or number
393
 
and allows for specifying a set of possible values for a parameter. At
394
 
deployment time, the user provided value for the respective parameter must
395
 
match one of the elements of the specified list. The syntax of the
396
 
allowed_values constraint is:
397
 
 
398
 
::
399
 
 
400
 
  allowed_values: [ <value>, <value>, ... ]
401
 
 
402
 
Alternatively, the YAML bulleted list notation can be used:
403
 
 
404
 
::
405
 
 
406
 
  allowed_values:
407
 
    - <value>
408
 
    - <value>
409
 
    - ...
410
 
 
411
 
For example:
412
 
 
413
 
::
414
 
 
415
 
  parameters:
416
 
    instance_type:
417
 
      type: string
418
 
      label: Instance Type
419
 
      description: Instance type for compute instances
420
 
      constraints:
421
 
        - allowed_values:
422
 
          - m1.small
423
 
          - m1.medium
424
 
          - m1.large
 
409
++++++++++++++
 
410
The ``allowed_values`` constraint applies to parameters of type
 
411
``string`` or ``number``. It specifies a set of possible values for a
 
412
parameter. At deployment time, the user-provided value for the
 
413
respective parameter must match one of the elements of the list.
 
414
 
 
415
The syntax of the ``allowed_values`` constraint is::
 
416
 
 
417
   allowed_values: [ <value>, <value>, ... ]
 
418
 
 
419
Alternatively, the following YAML list notation can be used::
 
420
 
 
421
   allowed_values:
 
422
     - <value>
 
423
     - <value>
 
424
     - ...
 
425
 
 
426
For example::
 
427
 
 
428
   parameters:
 
429
     instance_type:
 
430
       type: string
 
431
       label: Instance Type
 
432
       description: Instance type for compute instances
 
433
       constraints:
 
434
         - allowed_values:
 
435
           - m1.small
 
436
           - m1.medium
 
437
           - m1.large
425
438
 
426
439
allowed_pattern
427
 
~~~~~~~~~~~~~~~
428
 
The *allowed_pattern* constraint applies to parameters of type string and allows
429
 
for specifying a regular expression against which a user provided parameter
430
 
value must evaluate at deployment.
431
 
The syntax of the allowed_pattern constraint is:
432
 
 
433
 
::
434
 
 
435
 
  allowed_pattern: <regular expression>
436
 
 
437
 
For example:
438
 
 
439
 
::
440
 
 
441
 
  parameters:
442
 
    user_name:
443
 
      type: string
444
 
      label: User Name
445
 
      description: User name to be configured for the application
446
 
      constraints:
447
 
        - allowed_pattern: "[A-Z]+[a-zA-Z0-9]*"
 
440
+++++++++++++++
 
441
The ``allowed_pattern`` constraint applies to parameters of type
 
442
``string``. It specifies a regular expression against which a
 
443
user-provided parameter value must evaluate at deployment.
 
444
 
 
445
The syntax of the ``allowed_pattern`` constraint is::
 
446
 
 
447
   allowed_pattern: <regular expression>
 
448
 
 
449
For example::
 
450
 
 
451
   parameters:
 
452
     user_name:
 
453
       type: string
 
454
       label: User Name
 
455
       description: User name to be configured for the application
 
456
       constraints:
 
457
         - allowed_pattern: "[A-Z]+[a-zA-Z0-9]*"
448
458
          description: User name must start with an uppercase character
449
459
 
450
460
 
451
461
custom_constraint
452
 
~~~~~~~~~~~~~~~~~
453
 
The *custom_constraint* constraint adds an extra step of validation, generally
454
 
to check that the specified resource exists in the backend. Custom constraints
455
 
get implemented by plug-ins and can provide any kind of advanced constraint
456
 
validation logic.
457
 
 
458
 
The syntax of the custom_constraint constraint is:
459
 
 
460
 
::
461
 
 
462
 
  custom_constraint: <name>
463
 
 
464
 
The *name* specifies the concrete type of custom constraint. It corresponds to
465
 
the name under which the respective validation plugin has been registered with
466
 
the heat-engine.
467
 
 
468
 
For example:
469
 
 
470
 
::
471
 
 
472
 
  parameters:
473
 
    key_name
474
 
      type: string
475
 
      description: SSH key pair
476
 
      constraints:
477
 
        - custom_constraint: nova.keypair
 
462
+++++++++++++++++
 
463
The ``custom_constraint`` constraint adds an extra step of validation,
 
464
generally to check that the specified resource exists in the backend. Custom
 
465
constraints get implemented by plug-ins and can provide any kind of advanced
 
466
constraint validation logic.
 
467
 
 
468
The syntax of the ``custom_constraint`` constraint is::
 
469
 
 
470
   custom_constraint: <name>
 
471
 
 
472
The ``name`` attribute specifies the concrete type of custom constraint. It
 
473
corresponds to the name under which the respective validation plugin has been
 
474
registered in the Orchestration engine.
 
475
 
 
476
For example::
 
477
 
 
478
   parameters:
 
479
     key_name
 
480
       type: string
 
481
       description: SSH key pair
 
482
       constraints:
 
483
         - custom_constraint: nova.keypair
478
484
 
479
485
.. _hot_spec_pseudo_parameters:
480
486
 
481
 
Pseudo Parameters
 
487
Pseudo parameters
482
488
-----------------
483
 
 
484
489
In addition to parameters defined by a template author, Heat also
485
490
creates three parameters for every stack that allow referential access
486
491
to the stack's name, stack's identifier and project's
487
492
identifier. These parameters are named ``OS::stack_name`` for the
488
493
stack name, ``OS::stack_id`` for the stack identifier and
489
494
``OS::project_id`` for the project identifier. These values are
490
 
accessible via the `get_param`_ intrinsic function just like
 
495
accessible via the `get_param`_ intrinsic function, just like
491
496
user-defined parameters.
492
497
 
493
498
.. note::
496
501
 
497
502
.. _hot_spec_resources:
498
503
 
499
 
-----------------
500
 
Resources Section
501
 
-----------------
502
 
 
503
 
In the *resources* section, the templates for actual resources that will make up
504
 
a stack deployed from the HOT template (e.g. compute instances, networks,
505
 
storage volumes) are defined.
506
 
Each resource is defined as a separate block in the resources section according
507
 
to the syntax below.
508
 
 
509
 
::
510
 
 
511
 
  resources:
512
 
    <resource ID>:
513
 
      type: <resource type>
514
 
      properties:
515
 
        <property name>: <property value>
516
 
      metadata:
517
 
        <resource specific metadata>
518
 
      depends_on: <resource ID or list of ID>
519
 
      update_policy: <update policy>
520
 
      deletion_policy: <deletion policy>
 
504
 
 
505
Resources section
 
506
~~~~~~~~~~~~~~~~~
 
507
The ``resources`` section defines actual resources that make up a stack
 
508
deployed from the HOT template (for instance compute instances, networks,
 
509
storage volumes).
 
510
 
 
511
Each resource is defined as a separate block in the ``resources`` section with
 
512
the following syntax::
 
513
 
 
514
   resources:
 
515
     <resource ID>:
 
516
       type: <resource type>
 
517
       properties:
 
518
         <property name>: <property value>
 
519
       metadata:
 
520
         <resource specific metadata>
 
521
       depends_on: <resource ID or list of ID>
 
522
       update_policy: <update policy>
 
523
       deletion_policy: <deletion policy>
521
524
 
522
525
resource ID
523
 
    A resource block is headed by the resource ID, which must be unique within
524
 
    the resource section of a template.
 
526
    A resource ID which must be unique within the ``resources`` section of the
 
527
    template.
 
528
 
525
529
type
526
 
    This attribute specifies the type of resource, such as OS::Nova::Server.
 
530
    The resource type, such as ``OS::Nova::Server`` or ``OS::Neutron::Port``.
 
531
    This attribute is required.
 
532
 
527
533
properties
528
 
    This *optional* section contains a list of resource specific properties.
529
 
    The property value can be provided in place, or can be provided via a
530
 
    function (see :ref:`hot_spec_intrinsic_functions`).
 
534
    A list of resource-specific properties. The property value can be provided
 
535
    in place, or via a function (see :ref:`hot_spec_intrinsic_functions`).
 
536
    This section is optional.
 
537
 
531
538
metadata
532
 
    This *optional* section contains resource type specific metadata.
 
539
    Resource-specific metadata.
 
540
    This section is optional.
 
541
 
533
542
depends_on
534
 
    This *optional* attribute allows for specifying dependencies of the current
535
 
    resource on one or more other resources. Please refer to section
536
 
    :ref:`hot_spec_resources_dependencies` for details.
537
 
update_policy:
538
 
   This *optional* attribute allows for specifying an update policy for the
539
 
   resource in the form of a nested dictionary (name-value pairs). Whether
540
 
   update policies are supported and what the exact semantics are depends on
541
 
   the type of the current resource.
542
 
deletion_policy:
543
 
   This *optional* attribute allows for specifying a deletion policy for the
544
 
   resource (one of the values Delete, Retain or Snapshot). Which type of
545
 
   deletion policy is supported depends on the type of the current resource.
546
 
 
 
543
    Dependencies of the resource on one or more resources of the template.
 
544
    See :ref:`hot_spec_resources_dependencies` for details.
 
545
    This attribute is optional.
 
546
 
 
547
update_policy
 
548
    Update policy for the resource, in the form of a nested dictionary. Whether
 
549
    update policies are supported and what the exact semantics are depends on
 
550
    the type of the current resource.
 
551
    This attribute is optional.
 
552
 
 
553
deletion_policy
 
554
    Deletion policy for the resource. Which type of deletion policy is
 
555
    supported depends on the type of the current resource.
 
556
    This attribute is optional.
547
557
 
548
558
Depending on the type of resource, the resource block might include more
549
 
resource specific data. Basically all resource types that can be used in
550
 
CFN templates can also be used in HOT templates, adapted to the YAML structure
551
 
as outlined above.
552
 
Below is an example of a simple compute resource definition with some fixed
553
 
property values.
554
 
 
555
 
::
556
 
 
557
 
  resources:
558
 
    my_instance:
559
 
      type: OS::Nova::Server
560
 
      properties:
561
 
        flavor: m1.small
562
 
        image: F18-x86_64-cfntools
 
559
resource specific data.
 
560
 
 
561
All resource types that can be used in CFN templates can also be used in HOT
 
562
templates, adapted to the YAML structure as outlined above.
 
563
 
 
564
The following example demonstrates the definition of a simple compute resource
 
565
with some fixed property values::
 
566
 
 
567
   resources:
 
568
     my_instance:
 
569
       type: OS::Nova::Server
 
570
       properties:
 
571
         flavor: m1.small
 
572
         image: F18-x86_64-cfntools
563
573
 
564
574
 
565
575
.. _hot_spec_resources_dependencies:
566
576
 
567
 
Resource Dependencies
 
577
Resource dependencies
568
578
---------------------
569
 
 
570
 
By means of the *depends_on* attribute within a resource section it is possible
571
 
to define a dependency between a resource and one or more other resources. If
572
 
a resource depends on just one other resource, the ID of the other resource is
573
 
specified as value of the *depends_on* attribute as shown in the following
574
 
example.
575
 
 
576
 
::
577
 
 
578
 
  resources:
579
 
    server1:
580
 
      type: OS::Nova::Server
581
 
      depends_on: server2
582
 
 
583
 
    server2:
584
 
      type: OS::Nova::Server
585
 
 
586
 
If a resource depends on more than one other resource, the value of the
587
 
*depends_on* attribute is specified as a list of resource IDs as shown in the
588
 
following example:
589
 
 
590
 
::
591
 
 
592
 
  resources:
593
 
    server1:
594
 
      type: OS::Nova::Server
595
 
      depends_on: [ server2, server3 ]
596
 
 
597
 
    server2:
598
 
      type: OS::Nova::Server
599
 
 
600
 
    server3:
601
 
      type: OS::Nova::Server
 
579
The ``depends_on`` attribute of a resource defines a dependency between this
 
580
resource and one or more other resources.
 
581
 
 
582
If a resource depends on just one other resource, the ID of the other resource
 
583
is specified as string of the ``depends_on`` attribute, as shown in the
 
584
following example::
 
585
 
 
586
   resources:
 
587
     server1:
 
588
       type: OS::Nova::Server
 
589
       depends_on: server2
 
590
 
 
591
     server2:
 
592
       type: OS::Nova::Server
 
593
 
 
594
If a resource depends on more than one other resources, the value of the
 
595
``depends_on`` attribute is specified as a list of resource IDs, as shown in
 
596
the following example::
 
597
 
 
598
   resources:
 
599
     server1:
 
600
       type: OS::Nova::Server
 
601
       depends_on: [ server2, server3 ]
 
602
 
 
603
     server2:
 
604
       type: OS::Nova::Server
 
605
 
 
606
     server3:
 
607
       type: OS::Nova::Server
602
608
 
603
609
 
604
610
.. _hot_spec_outputs:
605
611
 
606
 
---------------
607
 
Outputs Section
608
 
---------------
609
 
 
610
 
In the *outputs* section, any output parameters that should be available to the
611
 
user can be defined. Typically, this would be, for example, parameters such as
612
 
IP addresses of deployed instances, or URLs of web applications deployed as part
613
 
of a stack.
 
612
Outputs section
 
613
~~~~~~~~~~~~~~~
 
614
The ``outputs`` section defines output parameters that should be available to
 
615
the user after a stack has been created. This would be, for example, parameters
 
616
such as IP addresses of deployed instances, or URLs of web applications
 
617
deployed as part of a stack.
614
618
 
615
619
Each output parameter is defined as a separate block within the outputs section
616
 
according to the following syntax:
617
 
 
618
 
::
619
 
 
620
 
  outputs:
621
 
    <parameter name>:
622
 
      description: <description>
623
 
      value: <parameter value>
 
620
according to the following syntax::
 
621
 
 
622
   outputs:
 
623
     <parameter name>:
 
624
       description: <description>
 
625
       value: <parameter value>
624
626
 
625
627
parameter name
626
 
    An output parameter block is headed by the output parameter name, which must
627
 
    be unique within the outputs section of a template.
 
628
    The output parameter name, which must be unique within the ``outputs``
 
629
    section of a template.
 
630
 
628
631
description
629
 
    This element gives a short description of the output parameter.
 
632
    A short description of the output parameter.
 
633
    This attribute is optional.
 
634
 
630
635
parameter value
631
 
    This element specifies the value of the output parameter. Typically, this
632
 
    will be resolved by means of a function, e.g. by getting an attribute value
633
 
    of one of the stack's resources (see also
634
 
    :ref:`hot_spec_intrinsic_functions`).
635
 
 
636
 
The example below shows, how the IP address of a compute resource can be defined
637
 
as an output parameter.
638
 
 
639
 
::
640
 
 
641
 
  outputs:
642
 
    instance_ip:
643
 
      description: IP address of the deployed compute instance
644
 
      value: { get_attr: [my_instance, first_address] }
 
636
    The value of the output parameter. This value is usually resolved by means
 
637
    of a function. See :ref:`hot_spec_intrinsic_functions` for details about
 
638
    the functions.
 
639
    This attribute is required.
 
640
 
 
641
The example below shows how the IP address of a compute resource can
 
642
be defined as an output parameter::
 
643
 
 
644
   outputs:
 
645
     instance_ip:
 
646
       description: IP address of the deployed compute instance
 
647
       value: { get_attr: [my_instance, first_address] }
645
648
 
646
649
 
647
650
.. _hot_spec_intrinsic_functions:
648
651
 
649
 
-------------------
650
 
Intrinsic Functions
651
 
-------------------
652
 
HOT provides a set of intrinsic functions that can be used inside HOT templates
 
652
Intrinsic functions
 
653
~~~~~~~~~~~~~~~~~~~
 
654
HOT provides a set of intrinsic functions that can be used inside templates
653
655
to perform specific tasks, such as getting the value of a resource attribute at
654
 
runtime. A definition of all intrinsic functions available in HOT is given
655
 
below.
 
656
runtime. The following section describes the role and syntax of the intrinsic
 
657
functions.
656
658
 
657
659
 
658
660
get_attr
659
661
--------
660
 
The *get_attr* function allows referencing an attribute of a resource. At
661
 
runtime, it will be resolved to the value of an attribute of a resource instance
662
 
created from the respective resource definition of the template. Path based
663
 
attribute refrencing using keys or indexes requires heat_template_version
664
 
'2014-10-16'or higher.
665
 
The syntax of the get_attr function is as follows:
666
 
 
667
 
::
 
662
The ``get_attr`` function references an attribute of a
 
663
resource. The attribute value is resolved at runtime using the resource
 
664
instance created from the respective resource definition.
 
665
 
 
666
Path based attribute referencing using keys or indexes requires
 
667
``heat_template_version`` ``2014-10-16`` or higher.
 
668
 
 
669
The syntax of the ``get_attr`` function is::
668
670
 
669
671
  get_attr:
670
672
    - <resource name>
674
676
    - ...
675
677
 
676
678
resource name
677
 
    This parameter specifies the resource for which the attributes shall be
678
 
    resolved. This resource must be defined within the *resources* section of
679
 
    the template (see also :ref:`hot_spec_resources`).
 
679
    The resource name for which the attribute needs to be resolved.
 
680
 
 
681
    The resource name must exist in the ``resources`` section of the template.
 
682
 
680
683
attribute name
681
 
    The attribute name is required as it specifies the attribute
682
 
    to be resolved. If the attribute returns a complex data structure
683
 
    such as a list or a map, then subsequent keys or indexes can be specified
684
 
    which navigate the data structure to return the desired value.
685
 
 
686
 
Some examples of how to use the get_attr function are shown below:
687
 
 
688
 
::
689
 
 
690
 
  resources:
691
 
    my_instance:
692
 
      type: OS::Nova::Server
693
 
      # ...
694
 
 
695
 
  outputs:
696
 
    instance_ip:
697
 
      description: IP address of the deployed compute instance
698
 
      value: { get_attr: [my_instance, first_address] }
699
 
    instance_private_ip:
700
 
      description: Private IP address of the deployed compute instance
701
 
      value: { get_attr: [my_instance, networks, private, 0] }
702
 
 
703
 
In this example, if the networks attribute contained the following data:
704
 
 
705
 
::
 
684
    The attribute name to be resolved. If the attribute returns a complex data
 
685
    structure such as a list or a map, then subsequent keys or indexes can be
 
686
    specified. These additional parameters are used to navigate the data
 
687
    structure to return the desired value.
 
688
 
 
689
The following example demonstrates how to use the :code:`get_attr` function::
 
690
 
 
691
    resources:
 
692
      my_instance:
 
693
        type: OS::Nova::Server
 
694
        # ...
 
695
 
 
696
    outputs:
 
697
      instance_ip:
 
698
        description: IP address of the deployed compute instance
 
699
        value: { get_attr: [my_instance, first_address] }
 
700
      instance_private_ip:
 
701
        description: Private IP address of the deployed compute instance
 
702
       value: { get_attr: [my_instance, networks, private, 0] }
 
703
 
 
704
In this example, if the ``networks`` attribute contained the following data::
706
705
 
707
706
   {"public": ["2001:0db8:0000:0000:0000:ff00:0042:8329", "1.2.3.4"],
708
707
    "private": ["10.0.0.1"]}
709
708
 
710
 
then the value of the get_attr function would resolve to "10.0.0.1".
 
709
then the value of :code:`get_attr` function would resolve to ``10.0.0.1``
 
710
(first item of the ``private`` entry in the ``networks`` map).
711
711
 
712
712
 
713
713
get_file
714
 
------------
715
 
The *get_file* function allows string content to be substituted into the
716
 
template. It is generally used as a file inclusion mechanism for files
717
 
containing non-heat scripts or configuration files.
718
 
The syntax of the get_file function is as follows:
719
 
 
720
 
::
721
 
 
722
 
  get_file: <content key>
723
 
 
724
 
The *content key* will be used to look up the files dictionary that is
725
 
provided in the REST API call. The *heat* client command from
726
 
python-heatclient is *get_file* aware and will populate the *files* with
727
 
the actual content of fetched paths and URLs. The *heat* client command
728
 
supports relative paths and will transform these to absolute URLs which
729
 
will be used as the *content key* in the files dictionary.
730
 
 
731
 
Note: The argument to *get_file* should be a static path or URL and not
732
 
rely on intrinsic functions like *get_param*. In general, the *heat* client
733
 
does not process intrinsic functions (they are only processed by the heat
734
 
server).
735
 
 
736
 
The example below demonstrates *get_file* usage with both relative and
737
 
absolute URLs.
738
 
 
739
 
::
 
714
--------
 
715
The ``get_file`` function returns the content of a file into the template.
 
716
It is generally used as a file inclusion mechanism for files
 
717
containing scripts or configuration files.
 
718
 
 
719
The syntax of ``get_file`` function is::
 
720
 
 
721
   get_file: <content key>
 
722
 
 
723
The ``content key`` is used to look up the ``files`` dictionary that is
 
724
provided in the REST API call. The Orchestration client command
 
725
(``heat``) is ``get_file`` aware and populates the ``files``
 
726
dictionary with the actual content of fetched paths and URLs. The
 
727
Orchestration client command supports relative paths and transforms these
 
728
to the absolute URLs required by the Orchestration API.
 
729
 
 
730
.. note::
 
731
    The ``get_file`` argument must be a static path or URL and not rely on
 
732
    intrinsic functions like ``get_param``. the Orchestration client does not
 
733
    process intrinsic functions (they are only processed by the Orchestration
 
734
    engine).
 
735
 
 
736
The example below demonstrates the ``get_file`` function usage with both
 
737
relative and absolute URLs::
740
738
 
741
739
  resources:
742
740
    my_instance:
752
750
        user_data:
753
751
          get_file: http://example.com/my_other_instance_user_data.sh
754
752
 
755
 
If this template was launched from a local file this would result in
756
 
a *files* dictionary containing entries with keys
757
 
*file:///path/to/my_instance_user_data.sh* and
758
 
*http://example.com/my_other_instance_user_data.sh*.
 
753
The ``files`` dictionary generated by the Orchestration client during
 
754
instantiation of the stack would contain the following keys:
 
755
 
 
756
* :file:`file:///path/to/my_instance_user_data.sh`
 
757
* :file:`http://example.com/my_other_instance_user_data.sh`
759
758
 
760
759
 
761
760
get_param
762
761
---------
763
 
The *get_param* function allows for referencing an input parameter of a template
764
 
from anywhere within a template. At runtime, it will be resolved to the value
765
 
provided for this input parameter. The syntax of the *get_param* function is as
766
 
follows:
767
 
 
768
 
::
769
 
 
770
 
  get_param:
771
 
    - <parameter name>
772
 
    - <key/index 1> (optional)
773
 
    - <key/index 2> (optional)
774
 
    - ...
 
762
The ``get_param`` function references an input parameter of a template. It
 
763
resolves to the value provided for this input parameter at runtime.
 
764
 
 
765
The syntax of the ``get_param`` function is::
 
766
 
 
767
    get_param:
 
768
     - <parameter name>
 
769
     - <key/index 1> (optional)
 
770
     - <key/index 2> (optional)
 
771
     - ...
775
772
 
776
773
parameter name
777
 
    The parameter name is required as it specifies the parameter
778
 
    to be resolved. If the parameter returns a complex data structure
779
 
    such as a list or a map, then subsequent keys or indexes can be specified
780
 
    which navigate the data structure to return the desired value.
781
 
 
782
 
A sample use of this function in context of a resource definition
783
 
is shown below.
784
 
 
785
 
::
786
 
 
787
 
  parameters:
788
 
    instance_type:
789
 
      type: string
790
 
      label: Instance Type
791
 
      description: Instance type to be used.
792
 
    server_data:
793
 
      type: json
794
 
 
795
 
  resources:
796
 
    my_instance:
797
 
      type: OS::Nova::Server
798
 
      properties:
799
 
        flavor: { get_param: instance_type}
800
 
        metadata: { get_param: [ server_data, metadata ] }
801
 
        key_name: { get_param: [ server_data, keys, 0 ] }
802
 
 
803
 
 
804
 
In this example, if the instance_type/server_data parameters contained
805
 
the following data:
806
 
 
807
 
::
808
 
 
809
 
   {"instance_type": "m1.tiny",
810
 
   {"server_data": {"metadata": {"foo": "bar"},
811
 
                    "keys": ["a_key","other_key"]}}}
812
 
 
813
 
then the value of the property 'flavor' would resolve to "m1.tiny", 'metadata'
814
 
would resolve to {"foo": "bar"} and 'key_name' would resolve to "a_key".
 
774
    The parameter name to be resolved. If the parameters returns a complex data
 
775
    structure such as a list or a map, then subsequent keys or indexes can be
 
776
    specified. These additional parameters are used to navigate the data
 
777
    structure to return the desired value.
 
778
 
 
779
The following example demonstrates the use of the ``get_param`` function::
 
780
 
 
781
    parameters:
 
782
       instance_type:
 
783
        type: string
 
784
        label: Instance Type
 
785
        description: Instance type to be used.
 
786
      server_data:
 
787
        type: json
 
788
 
 
789
    resources:
 
790
      my_instance:
 
791
        type: OS::Nova::Server
 
792
        properties:
 
793
          flavor: { get_param: instance_type}
 
794
          metadata: { get_param: [ server_data, metadata ] }
 
795
          key_name: { get_param: [ server_data, keys, 0 ] }
 
796
 
 
797
In this example, if the ``instance_type`` and ``server_data`` parameters
 
798
contained the following data::
 
799
 
 
800
    {"instance_type": "m1.tiny",
 
801
    {"server_data": {"metadata": {"foo": "bar"},
 
802
                     "keys": ["a_key","other_key"]}}}
 
803
 
 
804
then the value of the property ``flavor`` would resolve to ``m1.tiny``,
 
805
``metadata`` would resolve to ``{"foo": "bar"}`` and ``key_name`` would resolve
 
806
to ``a_key``.
 
807
 
815
808
 
816
809
get_resource
817
810
------------
818
 
The *get_resource* function allows for referencing another resource within the
819
 
same template. At runtime, it will be resolved to reference ID of the resource,
820
 
which is resource type specific. For example, a reference to a floating IP
821
 
resource will return the respective IP address at runtime.
822
 
The syntax of the get_resource function is as follows:
823
 
 
824
 
::
825
 
 
826
 
  get_resource: <resource ID>
827
 
 
828
 
The *resource ID* of the referenced resources as used in the current template is
829
 
given as single parameter to the get_resource function.
 
811
The ``get_resource`` function references another resource within the
 
812
same template. At runtime, it is resolved to reference the ID of the referenced
 
813
resource, which is resource type specific. For example, a reference to a
 
814
floating IP resource returns the respective IP address at runtime.  The syntax
 
815
of the ``get_resource`` function is::
 
816
 
 
817
    get_resource: <resource ID>
 
818
 
 
819
The resource ID of the referenced resource is given as single parameter to the
 
820
``get_resource`` function.
 
821
 
 
822
For example::
 
823
 
 
824
   resources:
 
825
     instance_port:
 
826
       type: OS::Neutron::Port
 
827
       properties: ...
 
828
 
 
829
     instance:
 
830
       type: OS::Nova::Server
 
831
       properties:
 
832
         ...
 
833
         networks:
 
834
           port: { get_resource: instance_port }
830
835
 
831
836
 
832
837
list_join
833
838
---------
834
 
The *list_join* function joins a list of strings with the given delimiter. This
835
 
function is introduced in the Juno release, usable in HOT versions later than
836
 
`2013-05-23`.  The syntax of the list_join function is as follows:
837
 
 
838
 
::
839
 
 
840
 
  list_join:
841
 
  - <delimiter>
842
 
  - <list to join>
843
 
 
844
 
A sample use of this function with a simple list is shown below.
845
 
 
846
 
::
847
 
 
848
 
  list_join: [', ', ['one', 'two', 'and three']]
849
 
 
850
 
This would resolve to "one, two, and three".
 
839
The ``list_join`` function joins a list of strings with the given delimiter.
 
840
 
 
841
The syntax of the ``list_join`` function is::
 
842
 
 
843
    list_join:
 
844
    - <delimiter>
 
845
    - <list to join>
 
846
 
 
847
For example::
 
848
 
 
849
   list_join: [', ', ['one', 'two', 'and three']]
 
850
 
 
851
This resolve to the string ``one, two, and three``.
851
852
 
852
853
 
853
854
digest
854
 
--------
855
 
The *digest* function allows for performing digest operations on a given value.
856
 
This function has been introduced in the Kilo release and is usable with HOT versions
857
 
later than `2015-04-30`.
858
 
 
859
 
The syntax of the digest function is as follows:
860
 
 
861
 
::
 
855
------
 
856
The ``digest`` function allows for performing digest operations on a given
 
857
value. This function has been introduced in the Kilo release and is usable with
 
858
HOT versions later than ``2015-04-30``.
 
859
 
 
860
The syntax of the ``digest`` function is::
862
861
 
863
862
  digest:
864
863
    - <algorithm>
869
868
    provided natively by hashlib (md5, sha1, sha224, sha256, sha384,
870
869
    and sha512) or any one provided by OpenSSL.
871
870
value
872
 
    The value to digest. This function will resolve to the corresponding hash of
873
 
    the value.
874
 
 
875
 
 
876
 
An example of how to use the digest function is shown below:
877
 
 
878
 
::
 
871
    The value to digest. This function will resolve to the corresponding hash
 
872
    of the value.
 
873
 
 
874
 
 
875
For example::
879
876
 
880
877
  # from a user supplied parameter
881
878
  pwd_hash: { digest: ['sha512', { get_param: raw_password }] }
882
879
 
883
880
The value of the digest function would resolve to the corresponding hash of
884
 
the value of 'raw_password'.
 
881
the value of ``raw_password``.
885
882
 
886
883
 
887
884
repeat
888
885
------
889
 
The *repeat* function allows for dynamically transforming lists by iterating
 
886
The ``repeat`` function allows for dynamically transforming lists by iterating
890
887
over the contents of one or more source lists and replacing the list elements
891
888
into a template. The result of this function is a new list, where the elements
892
889
are set to the template, rendered for each list item.
893
890
 
894
 
The syntax of the repeat function is as follows:
895
 
 
896
 
::
 
891
The syntax of the ``repeat`` function is::
897
892
 
898
893
  repeat:
899
894
    template:
902
897
      <var>: <list>
903
898
 
904
899
template
905
 
    The *template* argument defines the content generated for each iteration,
 
900
    The ``template`` argument defines the content generated for each iteration,
906
901
    with placeholders for the elements that need to be replaced at runtime.
907
902
    This argument can be of any supported type.
908
903
for_each
909
 
    The *for_each* argument is a dictionary that defines how to generate the
 
904
    The ``for_each`` argument is a dictionary that defines how to generate the
910
905
    repetitions of the template and perform substitutions. In this dictionary
911
906
    the keys are the placeholder names that will be replaced in the template,
912
907
    and the values are the lists to iterate on. On each iteration, the function
915
910
    template will be rendered once for each element in the list. When more
916
911
    than one key/value pairs are given, the iterations will be performed on all
917
912
    the permutations of values between the given lists. The values in this
918
 
    dictionary can be given as functions such as get_attr or get_param.
919
 
 
920
 
The example below shows how a security group resource can be defined to
921
 
include a list of ports given as a parameter.
922
 
 
923
 
::
 
913
    dictionary can be given as functions such as ``get_attr`` or ``get_param``.
 
914
 
 
915
The following example shows how a security group resource can be defined to
 
916
include a list of ports given as a parameter::
924
917
 
925
918
    parameters:
926
919
      ports:
942
935
                port_range_min: %port%
943
936
                port_range_max: %port%
944
937
 
945
 
The next example demonstrates how the use of multiple lists enables the
946
 
security group to also include parameterized protocols.
947
 
 
948
 
::
 
938
The following example demonstrates how the use of multiple lists enables the
 
939
security group to also include parameterized protocols::
949
940
 
950
941
    parameters:
951
942
      ports:
977
968
 
978
969
resource_facade
979
970
---------------
980
 
The *resource_facade* function allows a provider template to retrieve data
981
 
about its resource facade in the parent template. A provider template is used
982
 
to provide a custom definition of a resource - the facade - in the form of a
983
 
Heat template. The resource's properties are passed to the provider template as
984
 
its parameters, but other resource data can be included using this function.)
985
 
 
986
 
The syntax of the *resource_facade* function is as follows::
987
 
 
988
 
  resource_facade: <data type>
989
 
 
990
 
The *data type* can be `metadata`, `deletion_policy` or `update_policy`.
 
971
The ``resource_facade`` function retrieves data in a parent
 
972
provider template.
 
973
 
 
974
A provider template provides a custom definition of a resource, called its
 
975
facade. For more information about custom templates, see :ref:`composition`.
 
976
The syntax of the ``resource_facade`` function is::
 
977
 
 
978
   resource_facade: <data type>
 
979
 
 
980
``data type`` can be one of ``metadata``, ``deletion_policy`` or
 
981
``update_policy``.
991
982
 
992
983
 
993
984
str_replace
994
985
-----------
995
 
The *str_replace* function allows for dynamically constructing strings by
 
986
The ``str_replace`` function dynamically constructs strings by
996
987
providing a template string with placeholders and a list of mappings to assign
997
988
values to those placeholders at runtime. The placeholders are replaced with
998
989
mapping values wherever a mapping key exactly matches a placeholder.
999
 
The syntax of the str_replace function is as follows:
1000
 
 
1001
 
::
1002
 
 
1003
 
  str_replace:
1004
 
    template: <template string>
1005
 
    params: <parameter mappings>
 
990
 
 
991
The syntax of the ``str_replace`` function is::
 
992
 
 
993
   str_replace:
 
994
     template: <template string>
 
995
     params: <parameter mappings>
1006
996
 
1007
997
template
1008
 
    The *template* argument defines the template string that contains
1009
 
    placeholders which will be substituted at runtime.
 
998
    Defines the template string that contains placeholders which will be
 
999
    substituted at runtime.
 
1000
 
1010
1001
params
1011
 
    The *params* argument provides parameter mappings in the form of a
1012
 
    dictionary, which will be used for placeholder substitution in the template
1013
 
    string at runtime. Within parameter mappings one can make use of other
1014
 
    functions (e.g. get_attr to use resource attribute values) for template
1015
 
    substitution.
1016
 
 
1017
 
The example below shows a simple use of the str_replace function in the outputs
1018
 
section of a template to build a URL for logging into a deployed application.
1019
 
 
1020
 
::
1021
 
 
1022
 
  resources:
1023
 
    my_instance:
1024
 
      type: OS::Nova::Server
1025
 
      # general metadata and properties ...
1026
 
 
1027
 
  outputs:
1028
 
    Login_URL:
1029
 
      description: The URL to log into the deployed application
1030
 
      value:
1031
 
        str_replace:
1032
 
          template: http://host/MyApplication
1033
 
          params:
1034
 
            host: { get_attr: [ my_instance, first_address ] }
1035
 
 
1036
 
The str_replace function can also be used for constructing bigger chunks of text
1037
 
like scripts for initializing compute instances as shown in the example below:
1038
 
 
1039
 
::
1040
 
 
1041
 
  parameters:
1042
 
    DBRootPassword:
1043
 
      type: string
1044
 
      label: Database Password
1045
 
      description: Root password for MySQL
1046
 
      hidden: true
1047
 
 
1048
 
  resources:
1049
 
    my_instance:
1050
 
      type: OS::Nova::Server
1051
 
      properties:
1052
 
        # general properties ...
1053
 
        user_data:
 
1002
    Provides parameter mappings in the form of dictionary. Each key refers to a
 
1003
    placeholder used in the ``template`` attribute.
 
1004
 
 
1005
The following example shows a simple use of the ``str_replace`` function in the
 
1006
outputs section of a template to build a URL for logging into a deployed
 
1007
application::
 
1008
 
 
1009
    resources:
 
1010
      my_instance:
 
1011
        type: OS::Nova::Server
 
1012
        # general metadata and properties ...
 
1013
 
 
1014
    outputs:
 
1015
      Login_URL:
 
1016
        description: The URL to log into the deployed application
 
1017
        value:
1054
1018
          str_replace:
1055
 
            template: |
1056
 
              #!/bin/bash
1057
 
              echo "Hello world"
1058
 
              echo "Setting MySQL root password"
1059
 
              mysqladmin -u root password $db_rootpassword
1060
 
              # do more things ...
 
1019
            template: http://host/MyApplication
1061
1020
            params:
1062
 
              $db_rootpassword: { get_param: DBRootPassword }
 
1021
              host: { get_attr: [ my_instance, first_address ] }
 
1022
 
 
1023
The following examples show the use of the ``str_replace``
 
1024
function to build an instance initialization script::
 
1025
 
 
1026
    parameters:
 
1027
      DBRootPassword:
 
1028
        type: string
 
1029
        label: Database Password
 
1030
        description: Root password for MySQL
 
1031
        hidden: true
 
1032
 
 
1033
    resources:
 
1034
      my_instance:
 
1035
        type: OS::Nova::Server
 
1036
        properties:
 
1037
          # general properties ...
 
1038
          user_data:
 
1039
            str_replace:
 
1040
              template: |
 
1041
                #!/bin/bash
 
1042
                echo "Hello world"
 
1043
                echo "Setting MySQL root password"
 
1044
                mysqladmin -u root password $db_rootpassword
 
1045
                # do more things ...
 
1046
              params:
 
1047
                $db_rootpassword: { get_param: DBRootPassword }
1063
1048
 
1064
1049
In the example above, one can imagine that MySQL is being configured on a
1065
1050
compute instance and the root password is going to be set based on a user
1066
1051
provided parameter. The script for doing this is provided as userdata to the
1067
 
compute instance, leveraging the str_replace function.
1068
 
 
1069
 
Fn::Select
1070
 
----------
1071
 
*Fn::Select* is a function borrowed from CFN template.  Please check the CFN
1072
 
template guide for a description.
 
1052
compute instance, leveraging the ``str_replace`` function.
 
1053
 
 
1054
 
 
1055
str_split
 
1056
---------
 
1057
The ``str_split`` function allows for splitting a string into a list by
 
1058
providing an arbitrary delimiter, the opposite of ``list_join``.
 
1059
 
 
1060
The syntax of the ``str_split`` function is as follows:
 
1061
 
 
1062
::
 
1063
 
 
1064
  str_split:
 
1065
    - ','
 
1066
    - string,to,split
 
1067
 
 
1068
Or::
 
1069
 
 
1070
  str_split: [',', 'string,to,split']
 
1071
 
 
1072
The result of which is::
 
1073
 
 
1074
  ['string', 'to', 'split']
 
1075
 
 
1076
Optionally, an index may be provided to select a specific entry from the
 
1077
resulting list, similar to ``get_attr``/``get_param``::
 
1078
 
 
1079
  str_split: [',', 'string,to,split', 0]
 
1080
 
 
1081
The result of which is::
 
1082
 
 
1083
  'string'
 
1084
 
 
1085
Note: The index starts at zero, and any value outside the maximum (e.g the
 
1086
length of the list minus one) will cause an error.