更新时间:2024-04-17 GMT+08:00
conditions
conditions为可选项,用于定义条件。通过条件可以控制定义在node_templates中的元素是否需要创建部署。
conditions格式:
<条件名称>:
<条件内置函数>
...
通过conditions控制node_templates中属性生效的格式如下:
node_templates:
<元素名称>:
condition: <条件名称>
...
|
属性 |
是否必选 |
参数类型 |
取值约束 |
描述 |
|---|---|---|---|---|
|
条件名称 |
是 |
字符串 |
由大写字母、小写字母、数字和中划线“-”组成,长度为[1-64]。 |
新建条件名,命名必须唯一。 |
|
条件内置函数 |
是 |
- |
- |
条件的定义需要通过条件内置函数来实现,详情请参见条件函数。 |
|
元素名称 |
是 |
字符串 |
由小写字母、数字和中划线“-”组成,长度为[1, 48]。 |
新建元素名,命名必须唯一。 |
|
条件名称 |
是 |
字符串 |
由大写字母、小写字母、数字和中划线“-”组成,长度为[1-64]。 |
在conditions中已定义的条件名称。 |
conditions配置样例:
通过条件控制元素是否创建部署,需要在inputs、conditions、node_templates等多个字段中定义引用关系。
tosca_definitions_version: cloud_tosca_version_1_0
conditions:
condition_vm_deploy: #inputs参数满足匹配时,条件才能满足
cond_eq:
- get_input: vm_deploy
- true
inputs:
image:
description: 云服务器使用的镜像ID
type: Cloud.ECS.Image.Id
instance:
default: 1
description: 创建云服务器数量
subnet:
description: 云服务器子网ID
vm_deploy: #输入参数,控制vm对象是否部署。
default: true
type: boolean
vpc:
description: 云服务器VPC的ID
node_templates:
vm:
condition: condition_vm_deploy #条件满足时,vm对象才会部署
type: Cloud.ECS.CloudServer
properties:
availabilityZone: ae-ad-1a
imageId:
get_input: image
flavor: s3.small.1
instances:
get_input: instance
name: my-ecs
nics:
- subnetId:
get_input: subnet
rootVolume:
size: 40
volumeType: SATA
vpcId:
get_input: vpc
myecs:
type: Cloud.ECS.CloudServer
properties:
name: my-ecs
instances:
get_input: instance
imageId:
get_input: image
flavor: s3.small.1
vpcId:
get_input: vpc
availabilityZone: ae-ad-1a
nics:
- subnetId:
get_input: subnet
rootVolume:
volumeType: SSD
size: 40
父主题: 模板简介