Heat模板全称为heat orchestration template,简称为HOT。
1 典型Heat模板结构
heat_template_version: 2015-04-30
description:
# a description of the template
parameter_groups:
# a declaration of input parameter groups and order
parameters:
# declaration of input parameters
resources:
# declaration of template resources
outputs:
# declaration of output parameters
2 heat_template_version
每个HOT需要包含 heat_template_version 字段,指明所使用的 HOT 版本。
每个版本支持的内置方法不同,比如2016-04-08版本支持的内置方法如下:
digest、 get_attr、get_file、get_param、get_resource、list_join、
map_merge、repeat、resource_façade、str_replace、str_split
3 parameter groups
用于指定参数的顺序,每个参数只能与指定的group关联一次。
parameter_groups:
- label: <human-readable label of parameter group>
description: <description of the parameter group>
parameters:
- <param name>
- <param name>
4 parameter
parameters:
<param name>:
type: <string | number | json | comma_delimited_list | boolean>
label: <human-readable name of the parameter>
description: <description of the parameter>
default: <default value for parameter>
hidden: <true | false>
constraints:
<parameter constraints>
immutable: <true | false>
示例:
parameters:
user_name:
type: string
label: User Name
description: User name to be configured for the application
port_number:
type: number
label: Port Number
description: Port number to be configured for the web server
parameter type:
Type | Description | Examples |
string | A literal string. | “String param” |
number | An integer or float. | “2”; “0.2” |
comma_delimited_list | An array of literal strings that are separated by commas. The total number of strings should be one more than the total number of commas. | [“one”, “two”]; “one, two”; Note: “one, two” returns [“one”, ” two”] |
json | A JSON-formatted map or list. | {“key”: “value”} |
boolean | Boolean type value, which can be equal “t”, “true”, “on”, “y”, “yes”, or “1” for true value and “f”, “false”, “off”, “n”, “no”, or “0” for false value. | “on”; “n” |
hidden:隐藏用户输入的信息,如密码,将 hidden 属性置为 true。
constraints:已有的内置参数:OS::stack_name、OS::stack_id、OS::project_id。
constraints:
- <constraint type>: <constraint definition>
description: <constraint description>
5 resources
resources:
<resource ID>:
type: <resource type>
properties:
<property name>: <property value>
metadata:
<resource specific metadata>
depends_on: <resource ID or list of ID>
update_policy: <update policy>
deletion_policy: <deletion policy>
示例:
resources:
my_instance:
type: OS::Nova::Server
properties:
flavor: m1.small
image: F18-x86_64-cfntools
资源依赖的示例:
resources:
server1:
type: OS::Nova::Server
depends_on: [ server2, server3 ]
server2:
type: OS::Nova::Server
6 outputs
outputs:
<parameter name>:
description: <description>
value: <parameter value>
示例:
outputs:
instance_ip:
description: IP address of the deployed compute instance
value: { get_attr: [my_instance, first_address] }
编者注:本文来自OpenStack开源团队工程师陈曾