openstack heat:根据条件向实例添加端口
openstack heat: Add port to instance based on condition
我只想在名称为 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 }
对模板进行上述更改失败
有人可以帮助我吗 .....
如果您阅读 specification,您会注意到仅在 Newton 中添加了对 conditions
部分的支持。所以你需要:
heat_template_version: newton
或者:
heat_template_version: 2016-10-14
或更高版本的等效项。如果您 运行 是早于 Newton 的 openstack 版本,您将无法使用此功能。
我只想在名称为 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 }
对模板进行上述更改失败
有人可以帮助我吗 .....
如果您阅读 specification,您会注意到仅在 Newton 中添加了对 conditions
部分的支持。所以你需要:
heat_template_version: newton
或者:
heat_template_version: 2016-10-14
或更高版本的等效项。如果您 运行 是早于 Newton 的 openstack 版本,您将无法使用此功能。