Ask Your Question
0

Heat - Attach multiple port to Instance repeat: for_each:

asked 2019-06-18 10:31:09 -0500

Cheos96 gravatar image

Hi, can someone help me please ?. I'm having a problem executing this heat template, when i execute it, i get this result:

2019-06-18 14:35:27Z [stack_server_1._instance]: CREATE_IN_PROGRESS state changed

2019-06-18 14:35:28Z [stack_server_1._instance]: CREATE_FAILED BadRequest: resources._instance: Invalid input for field/attribute port. Value: stack_instance_1_port_0. u'stack_instance_1_port_0' is not valid under any of the given schemas (HTTP 400) (Request-ID: req-62522274-8a05-4bf8-919a-2abd577b543c)

2019-06-18 14:35:28Z [stack_server_1]: CREATE_FAILED Resource CREATE failed: BadRequest: resources._instance: Invalid input for field/attribute port. Value: stack_instance_1_port_0. u'stack_instance_1_port_0' is not valid under any of the given schemas (HTTP 400) (Request-ID: req-62522274-8a05-4bf8-919a-2ab

parameters:

keypair:
    type: string
    label: KeyPair
    description: KeyPair of the deployed instance.

instance:
    type: string
    label: Instance
    description: Name of the deployed instance.

flavor:
    type: string
    label: Flavor ou Gabarit
    description: Flavor of the deployed instance.
    constraints:
        - custom_constraint: nova.flavor

image:
    type: string
    label: Image
    description: Image of the deployed instance.
    constraints:
        - custom_constraint: glance.image

zone:
    type: string
    label: Availability zone 
    description: Availability zone attached to the deployed instance.

list_ports: 
   type: comma_delimited_list
   label: List ports
   description: List ports.

resources:

_instance:
    type: OS::Nova::Server
    properties:
        name: { get_param: instance }
        image: { get_param: image }
        flavor: { get_param: flavor }
        key_name: { get_param: keypair }
        availability_zone: { get_param: zone }
        networks:
            repeat:
                for_each:
                    <%port%>: { get_param: list_ports }
                template:
                    port: '<%port%>'

I tried with just one port from the list, and it worked but i want my template to adapt to any list of given ports, so the problem isn't from the list of ports, see below:

resources:

  _instance:
    type: OS::Nova::Server
    properties:
        name: { get_param: instance }
        image: { get_param: image }
        flavor: { get_param: flavor }
        key_name: { if: ["create_Keypair", { get_resource: _keypair }, { get_param: keypair }] }
        availability_zone: { get_param: zone }
        networks:
            - port: { get_param: port_a } # here port_a is a string with just one port.
            - port: { get_param: port_b } # here port_b is a string with just one port.

I don't understand the problem is it the syntax of repeat: for_each ? Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-06-19 04:55:31 -0500

Cheos96 gravatar image

I found the solution : it was so simple x) the list should be a list of "id port" not "name port".

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: 2019-06-18 10:31:09 -0500

Seen: 57 times

Last updated: Jun 18