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)? 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.

1 Answers1

0

You can assign static IP to VM in heat template as mentioned below-

resources:
  myVM_port1:
    type: OS::Neutron::Port
    properties:
      name: "myVM_port1"
      network_id: { get_param: network_id } 
      fixed_ips: [{"subnet": { get_param: network-subnet }, "ip_address": { get_param: fixed-ip } }]

  myVM_1:
    type: OS::Nova::Server
    properties:
      name: "myVM"
      image: { get_param: cirros_Image }
      flavor: "m1.tiny"
      availability_zone: "compute1"
      networks:
      - port: { get_resource: myVM_port1 }
IRSHAD
  • 2,855
  • 30
  • 39