资源属性的 Openstack HEAT 条件
Openstack HEAT condition for resource properties
"Conditions (..) They can be associated with resources and resource properties in the resources section (..)" - 正如官方 openstack 文档所说,我可以做到这一点。但是附带的示例不包含 "resource properties".
我有我的示例,当用户可以将参数设置为不创建端口 2 并且不附加端口 2(因为端口 2 不存在)时:
parameters:
global_port2_create:
description: Do you want eth1 (port2)
type: string
default: true
conditions:
create_port2: {equals : [{get_param: global_port2_create}, "true"]}
resources:
node_port1:
type: OS::Neutron::Port
properties:
network_id: {get_param: global_port1_net_id }
fixed_ips:
- subnet_id: {get_param: global_port1_net_id }
- ip_address: {get_param: node_port1_ip }
security_groups: {get_param: global_port1_security_groups_ids}
node_port2:
type: OS::Neutron::Port
condition: create_port2
properties:
network_id: {get_param: global_port_net_id }
fixed_ips:
- subnet_id: {get_param: global_port2_net_id }
- ip_address: {get_param: node5_port2_ip }
security_groups: {get_param: global_port2_security_groups_ids}
node5_server:
type: OS::Nova::Server
depends_on: [ node5_port1, node5_port2 ]
properties:
name: some_name
image: { get_param: global_image }
availability_zone: some_az
networks:
- port: { get_resource: node5_port1 }
- port: { get_resource: node5_port2 } #How to use a condition here?
我知道,我可以用两个端口做一个 ResourceGroup 并迭代它们,但我不想要这个解决方案。
大概是这样的?
networks:
- port: { get_resource: node5_port1 }
- port:
condition: create_port2
get_resource: node5_port2
有人知道如何完成这个吗?
我有一个类似的用例并找到了解决方案。但是,如果这仍然是一个问题,请与可读性说再见:
networks: {if: [ "create_port2", [port: { get_resource: node5_port1 }, port: { get_resource: node5_port2 }], [port: { get_resource: node5_port1 }]}
你也可以这样写:
networks:
if:
- "create_port2"
- [port: { get_resource: node5_port1 }, port: { get_resource: node5_port2 }]
- [port: { get_resource: node5_port1 }]
甚至:
networks:
if:
- "create_port2"
- - port: { get_resource: node5_port1 }
- port: { get_resource: node5_port2 }
- - port: { get_resource: node5_port1 }
选择你的毒药!
"Conditions (..) They can be associated with resources and resource properties in the resources section (..)" - 正如官方 openstack 文档所说,我可以做到这一点。但是附带的示例不包含 "resource properties".
我有我的示例,当用户可以将参数设置为不创建端口 2 并且不附加端口 2(因为端口 2 不存在)时:
parameters:
global_port2_create:
description: Do you want eth1 (port2)
type: string
default: true
conditions:
create_port2: {equals : [{get_param: global_port2_create}, "true"]}
resources:
node_port1:
type: OS::Neutron::Port
properties:
network_id: {get_param: global_port1_net_id }
fixed_ips:
- subnet_id: {get_param: global_port1_net_id }
- ip_address: {get_param: node_port1_ip }
security_groups: {get_param: global_port1_security_groups_ids}
node_port2:
type: OS::Neutron::Port
condition: create_port2
properties:
network_id: {get_param: global_port_net_id }
fixed_ips:
- subnet_id: {get_param: global_port2_net_id }
- ip_address: {get_param: node5_port2_ip }
security_groups: {get_param: global_port2_security_groups_ids}
node5_server:
type: OS::Nova::Server
depends_on: [ node5_port1, node5_port2 ]
properties:
name: some_name
image: { get_param: global_image }
availability_zone: some_az
networks:
- port: { get_resource: node5_port1 }
- port: { get_resource: node5_port2 } #How to use a condition here?
我知道,我可以用两个端口做一个 ResourceGroup 并迭代它们,但我不想要这个解决方案。 大概是这样的?
networks:
- port: { get_resource: node5_port1 }
- port:
condition: create_port2
get_resource: node5_port2
有人知道如何完成这个吗?
我有一个类似的用例并找到了解决方案。但是,如果这仍然是一个问题,请与可读性说再见:
networks: {if: [ "create_port2", [port: { get_resource: node5_port1 }, port: { get_resource: node5_port2 }], [port: { get_resource: node5_port1 }]}
你也可以这样写:
networks:
if:
- "create_port2"
- [port: { get_resource: node5_port1 }, port: { get_resource: node5_port2 }]
- [port: { get_resource: node5_port1 }]
甚至:
networks:
if:
- "create_port2"
- - port: { get_resource: node5_port1 }
- port: { get_resource: node5_port2 }
- - port: { get_resource: node5_port1 }
选择你的毒药!