OpenStack Heat:根据条件将端口添加到实例



我只想在名称为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 }

我要添加端口" test_vm_port_routable",仅当名称为zee_1 ....

我在以下条件下尝试了,但它给出了错误:错误:模板部分无效:条件

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 }

随着对模板的上述更改,它正在失败
有人可以帮助我.....

如果您阅读了规范,您会注意到,仅在牛顿中添加了对conditions部分的支持。因此,您需要:

heat_template_version: newton

或:

heat_template_version: 2016-10-14

或以后版本的等效物。如果您比牛顿更早运行OpenStack版本,那么您根本将无法使用此功能。

相关内容

  • 没有找到相关文章

最新更新