Ask Your Question
0

openstack heat: Add port to instance based on condition

asked 2017-12-14 12:09:39 -0500

Naresh237 gravatar image

I want to add port to the instance only if the name is zee_1

template file:

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 }

I want to add port "test_vm_port_routable" only if name is zee_1....

I tried with below condition but it is giving error :ERROR: The template section is invalid: conditions

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 }

can some one help me in this .....

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-02-03 17:20:51 -0500

DId you get any solution ?. Btw for me its cribbing on condition:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-12-14 12:09:39 -0500

Seen: 167 times

Last updated: Dec 14 '17