我想仅在名称为zee_1
时才将端口添加到实例模板文件:
resources:
vm_port_routable:
type: OS::Neutron::Port
properties:
network: { get_param: abc_routable_net }
name:
str_replace:
template: $stack_$name_routable_port
params:
$stack: { get_param: stack }
$name: { get_param: vm_name }
security_groups: [{ get_param: security_group }]
fixed_ips:
- ip_address: { get_param: port_ip_routable }
test_vm_port_routable:
type: OS::Neutron::Port
properties:
network: { get_param: test_zee_routable_net }
name:
str_replace:
template: $stack_$name_routable_port
params:
$stack: { get_param: stack }
$name: { get_param: vm_name }
security_groups: [{ get_param: security_group }]
fixed_ips:
- ip_address: { get_param: test_port_ip_routable }
zee_server:
type: OS::Nova::Server
properties:
block_device_mapping_v2:
- boot_index: 0
delete_on_termination: false
volume_id: { get_resource: root_volume }
device_name: vda
device_type: disk
- boot_index: -1
delete_on_termination: false
volume_id: { get_param: backup_volume }
device_name: vdc
device_type: disk
flavor: { get_param: flavor }
key_name: { get_param: ssh_keypair }
name: { get_param: vm_name }
networks:
- port: { get_resource: vm_port_routable }
- port: { get_resource: test_vm_port_routable }
我想只在名字是zee_1时添加端口“test_vm_port_routable”....
我尝试了以下条件,但它给出了错误:错误:模板部分无效:条件
conditions:
create_prod_res: { equal: [{get_param: "vm_name"},"zee_1"]}
resources:
vm_port_routable:
type: OS::Neutron::Port
properties:
network: { get_param: abc_routable_net }
name:
str_replace:
template: $stack_$name_routable_port
params:
$stack: { get_param: stack }
$name: { get_param: vm_name }
security_groups: [{ get_param: security_group }]
fixed_ips:
- ip_address: { get_param: port_ip_routable }
test_vm_port_routable:
type: OS::Neutron::Port
properties:
network: { get_param: test_zee_routable_net }
name:
str_replace:
template: $stack_$name_routable_port
params:
$stack: { get_param: stack }
$name: { get_param: vm_name }
security_groups: [{ get_param: security_group }]
fixed_ips:
- ip_address: { get_param: test_port_ip_routable }
zee_server:
type: OS::Nova::Server
properties:
block_device_mapping_v2:
- boot_index: 0
delete_on_termination: false
volume_id: { get_resource: root_volume }
device_name: vda
device_type: disk
- boot_index: -1
delete_on_termination: false
volume_id: { get_param: backup_volume }
device_name: vdc
device_type: disk
flavor: { get_param: flavor }
key_name: { get_param: ssh_keypair }
name: { get_param: vm_name }
condition:create_prod_res
networks:
- port: { get_resource: vm_port_routable }
- port: { get_resource: test_vm_port_routable }
对模板的上述更改失败了 有人可以帮助我......
答案 0 :(得分:0)
如果您阅读specification,则会注意到conditions
部分的支持仅在牛顿中添加。所以你需要:
heat_template_version: newton
或者:
heat_template_version: 2016-10-14
或等效版本。如果您在牛顿之前运行openstack版本,则只是无法使用此功能。