Ask Your Question
0

HEAT template to attach an unknown number of ports (opened on different networks) to a server

asked 2017-10-31 10:44:55 -0500

AshishJak gravatar image

updated 2017-11-01 09:20:42 -0500

zaneb gravatar image

I am trying to open as many number of ports(OS::Neutron::Port) on the provider networks mentioned by the user(via the parameter file) and trying to attach them to the server(OS::Nova::Server) that is being created. How to achieve the above requirement?

heat_template_version: 2016-04-08

parameters:
    nwNames:
         type: comma_delimited_list
         description: The list of provider network names whose size is 'N'. N={X, Y,......N}

resources:
        portX:
           type: OS::Neutron::Port
           properties:
              network: { get_param: NetworkX }
              security_groups:
                  - { get_param: securityGroup }

        portY:
           type: OS::Neutron::Port
           properties:
              network: { get_param: NetworkY }
              security_groups:
                  - { get_param: securityGroup }

        portN:
       type: OS::Neutron::Port
           properties:
              network: { get_param: NetworkN }
              security_groups:
                  - { get_param: securityGroup }

    server1: 
        type: OS::Nova::Server
            depends_on: [ portX, portY,....PortN ]
            properties:
                image: { get_param: image }
                flavor: { get_param: flavor }
                name:  { get_param: [ vmNames, get_param: index ] }
                networks:
                    - port: { get_resource: portA }
                    - port: { get_resource: portB }

                    - port: { get_resource: portN }

outputs:

My attempt: I gave a try using the OS::Heat::ResourceGroup by creating all the required network ports within a single ResourceGroup, but I wasn't able to iterate through them in order to attach it to the server.

Thanks in Advance.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-11-01 09:29:05 -0500

zaneb gravatar image

Once you have the ResourceGroup, you can attach all of the ports in it to the server like this:

server1: 
    type: OS::Nova::Server
        properties:
            image: { get_param: image }
            flavor: { get_param: flavor }
            name:  { get_param: [ vmNames, get_param: index ] }
            networks:
                repeat:
                    template:
                        port: $port_id$
                    for_each:
                        $port_id$: {get_attr: [port_group, refs]}
edit flag offensive delete link more

Comments

Hi Zaneb,

Thanks for the reply.

I tried the same, but it is throwing the following error:

ERROR: Failed to validate: Failed to validate: resources[0]: The values of the "for_each" argument to "repeat" must be lists

AshishJak gravatar imageAshishJak ( 2017-11-02 02:22:56 -0500 )edit

It is failing exactly in this line wherein I try to assign the list of ports to $port_id$.

My guess: It might be considering $port_id$ as a string and since the function returns({get_attr: [port_group, refs]}) list, it($port_id$) might not be able to hold it.

AshishJak gravatar imageAshishJak ( 2017-11-02 02:23:11 -0500 )edit

Another attempt: Also, one more thing I tried was to declare a local variable in parameter section as a comma_delimited_list and used the same to hold the list that is returned by the function(get_attr: [port_group, refs]). But that approach reported that the comma_delimited_list variable is unknown

AshishJak gravatar imageAshishJak ( 2017-11-02 02:24:26 -0500 )edit

Further help would be really appreciated., Thanks in advance again.

(Sorry to add multiple comments. That was due to the limitation in size of the comments.)

AshishJak gravatar imageAshishJak ( 2017-11-02 02:25:32 -0500 )edit

It sounds very much like this bug, which was fixed in Ocata.

zaneb gravatar imagezaneb ( 2017-11-02 11:23:52 -0500 )edit
0

answered 2019-05-14 05:35:33 -0500

Sumit1269 gravatar image

Hi Ashish Can you please share the final script which you use to create a single sever with multiple port.

I need for the reference as i am trying to create multiple server with multiple network,port and subnet.

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-10-31 05:59:45 -0500

Seen: 736 times

Last updated: Nov 01 '17