赞
踩
Heat的模版是Heat的核心。
Heat 目前支持两种格式的模板,一种是基于 JSON 格式的 CFN 模板;另外一种是基于 YAML 格式的 HOT 模板。
CFN 模板主要是为了保持对 AWS 的兼容性。HOT 模板是 Heat 自有的,资源类型更加丰富,更能体现出 Heat 特点的模板。
此处只涉及HOT( Heat Orchestration Template)模板。
典型的 HOT 模板由下列元素构成:
模板版本、模板描述、参数组列表、参数列表、资源列表、输出列表、声明条件。
heat_template_version: 2016-10-14
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
conditions:
# declaration of conditions
元素说明:
1)heat_template_version: 必填字段,指定对应的模板版本,Heat会根据版本进行检验。
2)description: 选填字段,用于模板的描述
3)parameter_groups: 选填字段,允许指定如何对输入参数进行分组,以及提供参数的顺序。
4)parameters: 选填字段,指输入参数列表。允许指定实例化模板时必须提供的输入参数。这些参数通常用于部署时的每个自定义值(例如,设置自定义用户名或密码)。每个参数都在一个独立的嵌套块中指定,该嵌套块具有第一行中定义的参数的名称和其他属性,如嵌套元素定义的类型或默认值。
5)resources: 必填字段,指生成的 Stack 所包含的各种资源,比如服务器、卷、对象、存储和网络资源。可以定义资源间的依赖关系。
6)outputs: 选填字段,指生成的 Stack 暴露出来的信息,可以用来给用户使用,也可以用来作为输入提供给其它的 Stack。
7)conditions: 选填字段,定义了一个或多个条件,这些条件根据用户创建或更新stack时提供的输入参数值进行评估。条件可以与资源、资源属性和输出相关联。
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>
external_id: <external resource ID>
condition: <condition name or expression or boolean>
resources元素的key值当中,除了resource ID和type两个必选项外,其它都是可选项。
properties也是可选项。
(不同的properties有不同的可选项和必选项,例如OS::Nova::Server类型的properties就有必选项和可选项,因此如果使用OS::Nova::Server,则properties不能为空)。
具体参考:https://docs.openstack.org/heat/latest/template_guide/openstack.html
- heat_template_version: 2015-04-30 # heat模板版本必须有
-
- description: #描述项是可选的,建议添加详细描述
-
- resources: # resources选项是必须的
-
- my_instance:
-
- type: OS::Nova::Server
-
- properties:
-
- key_name: my_key
-
- image: ubuntu-trusty-x86_64
-
- flavor: m1.small
- heat_template_version: 2015-04-30
-
- description: Simple template to deploy a single compute instance
-
- parameters:
-
- image_id:
-
- type: string
-
- label: Image ID
-
- description: Image to be used for compute instance
-
- flavor:
-
- type: string
-
- label: Instance Type
-
- description: Type of instance (flavor) to be used
-
- default: m1.small # 如果用户没有为参数定义值,则在stack部署期间使用默认值。 如果模板没有为参数定义默认值,那么用户必须定义该值,否则stack创建失败。
-
- constraints:
-
- - allowed_values: [ m1.medium, m1.large, m1.xlarge ] # 约束列表限制输入参数的值
-
- description: Value must be one of m1.medium, m1.large or m1.xlarge.
-
- resources:
-
- my_instance:
-
- type: OS::Nova::Server
-
- properties:
-
- image: { get_param: image_id }
-
- flavor: { get_param: flavor }
-
heat stack-create / openstack stack create
heat stack-update / openstack stack update
heat stack-list / openstack stack list
heat stack-show / openstack stack show
heat stack-delete / openstack stack delete
heat output-list / openstack stack output list
heat output-show / openstack stack output show
heat stack-abandon / openstack stack abandon
heat stack-adopt / openstack stack adopt
heat stack-cancel-update / openstack stack update cancel
heat stack-preview / openstack stack update --dry-run
heat action-check / openstack stack check
heat action-resume / openstack stack resume
heat action-suspend / openstack stack suspend
heat hook-clear / openstack stack hook clear
heat hook-poll / openstack stack hook poll
heat resource-list / openstack stack resource list
heat resource-metadata / openstack stack resource metadata show
heat resource-show / openstack stack resource show
heat resource-signal / openstack stack resource signal
heat resource-type-list / openstack orchestration resource type list
heat resource-type-show / openstack orchestration resource type show
heat template-show / openstack stack template show
heat template-validate / openstack stack create --dry-run
heat template-version-list / openstack orchestration template version list
heat resource-type-template / openstack orchestration resource type show --format (hot|cfn)
heat event-list / openstack stack event list
heat event-show / openstack stack event show
heat config-create / openstack software config create
heat config-delete / openstack software config delete
heat config-show / openstack software config show
heat config-list / openstack software config list
heat deployment-create / openstack software deployment create
heat deployment-delete / openstack software deployment delete
heat deployment-list / openstack software deployment list
heat deployment-metadata-show / openstack software deployment metadata show
heat deployment-output-show / openstack software deployment output show
heat deployment-show / openstack software deployment show
heat stack-restore / openstack stack snapshot restore
heat stack-snapshot / openstack stack snapshot create
heat snapshot-delete / openstack stack snapshot delete
heat snapshot-list / openstack stack snapshot list
heat snapshot-show / openstack stack snapshot show
heat build-info / openstack orchestration build-info
heat service-list / openstack service list (need to integrate with existing command)
常见操作链接:
https://docs.openstack.org/python-heatclient/latest/cli/index.html
https://specs.openstack.org/openstack/heat-specs/specs/mitaka/python-openstackclient.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。