当前位置:   article > 正文

OpenStack Heat模板详解_openstack heat模板使用教程

openstack heat模板使用教程

Heat模板全称为heat orchestration template,简称为HOT。

 

典型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] } 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/70556
推荐阅读
相关标签
  

闽ICP备14008679号