Ask Your Question
0

Is there any way to get the IP assigned to a VM from a particular subnet and embed it in Heat orchestration template(given that the network has multiple subnets and we are creating one port only for all subnets)?

asked 2016-07-02 07:52:05 -0500

siddsr gravatar image

updated 2016-07-11 02:12:43 -0500

jtaguinerd gravatar image

Is there any way to get the IP assigned to a VM from a particular subnet and embed it in Heat orchestration template(given that the network has multiple subnets and we are creating one port only for all subnets)? I need this info for floating IP. As in case of port with multiple fixed addresses on a single port, we need to give the particular IP for creating floating IP.

The get_attr key is not very helpful. Here is the JSON representation.

        "TestVM_FIPTest1": {
            "type": "OS::Neutron::FloatingIP",
            "properties": {
                "floating_network_id": "public",
                "port_id": {
                    "get_resource": "TestVM_Test1sub2sub1_Port"
                },
                  "fixed_ip_address":
                  {
                        "get_attr": ["TestVM_Test1sub2sub1_Port", "fixed_ips", 1, "ip_address"]
                  }
            }
        }

The reason being I need to pass the index to get the IP assigned on the port. But there is no way of telling , from which subnet that IP is assigned (as there the multiple subnets mapped on that port) or which index has the IP assigned from the desired subnet

Right now I am using a single template to create all the resources at once.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-11 02:02:13 -0500

jtaguinerd gravatar image

I don't really understand what you are trying to do..but if you are just concerned how to attach a floating ip. You may want to check my template. I used a combination of str_replace and get_attr.

mysql_master:
type: "OS::Nova::Server"
properties:
  name: { get_param: master }
  key_name: { get_param: key_name }
  image: { get_param: image }
  networks: 
    - port: { get_resource: mysql_master_port1 }
  flavor: { get_param: flavor }
  admin_user: { get_param: admin_user }
  admin_pass: { get_param: admin_pass }
  user_data_format: RAW
  user_data:
    str_replace:
      params:
        __vm_name__: { get_param: master }
        ipaddy: { get_attr: [ mysql_master_floating_ip, floating_ip_address ] }
      template: |
                     :
                     :
                     :

  mysql_master_port1:
      type: OS::Neutron::Port
      properties:
          network_id: { get_param: data_net_id }
          fixed_ips:
            - subnet_id: { get_param: data_subnet_id }

  mysql_master_floating_ip:
      type: OS::Neutron::FloatingIP
      properties:
           floating_network_id: { get_param: public_net_id }
           port_id: { get_resource: mysql_master_port1 }

Hope that helps. Cheers :)

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: 2016-07-02 07:48:27 -0500

Seen: 177 times

Last updated: Jul 11 '16