在heat中有一个ResourceGroup资源,类型是“OS::Heat::ResourceGroup”。
从名称就能够大概猜到该资源的作用:资源组,组内可以包括一个或多个相同的嵌套资源。
通过resource-type-show命令查看该资源的信息,可以看到该资源有以下几项输入属性:
属性 | 类型 | 描述 |
count | number | 定义资源组包含子资源个数,默认1 |
index_var | string | 定义索引替换字符串,默认%index% |
removal_policies | comma_delimited_list | 定义要从资源组中删除的子资源,默认[] |
resource_def | json | 子资源定义,跟在模板中直接定义资源属性相同 |
另外,该资源的输出属性如下:
属性 | 描述 |
attributes | 输出子资源指定属性信息 |
refs | 输出所有子资源ID列表 |
show | 输出所有子资源详细信息 |
下面通过一个例子来演示ResourceGroup资源的使用。
编辑模板文件template.yaml如下:
heat_template_version: 2015-04-30
description: create a group of cinder volume
resources:
resgroup:
type: OS::Heat::ResourceGroup
properties:
count: 2
resource_def:
type: OS::Cinder::Volume
properties:
name: vol-%index%