Support repeat function without nested loops

Registered by huangtianhua

We provide the 'repeat' intrinsic function in Kilo:
https://blueprints.launchpad.net/heat/+spec/repeat-function

The 'repeat' function will do nested loops if 'for_each' has multiple key/values, something like this:
*********************
parameters:
      ports:
        type: comma_delimited_list
        label: ports
        default: "80,443,8080"
      protocols:
        type: comma_delimited_list
        label: protocols
        default: "tcp,udp"

    resources:
      security_group:
        type: OS::Neutron::SecurityGroup
        properties:
          name: web_server_security_group
          rules:
            repeat:
              for_each:
                %port%: { get_param: ports }
                %protocol%: { get_param: protocols }
              template:
                protocol: %protocol%
                port_range_min: %port%
*********************

and the result of the 'repeat' section is:
rules:
  - protocol: tcp
    port_range_min: 80
  - protocol: tcp
   port_range_min: 443
  - protocol: tcp
   port_range_min: 8080
  - protocol: udp
   port_range_min: 80
  - protocol: udp
   port_range_min: 443
  - protocol: udp
   port_range_min: 8080

But sometimes, user don't want to nested loops, such as user want to create a server with five nics, and user hope to specify some properties of these nics, such as 'network', 'subnet' and 'fixed_ip':

parameters:
      nets:
        type: comma_delimited_list
        default: "net1, net2, net3, net4, net5"
      subnets:
        type: comma_delimited_list
        default: "sub1, sub2, sub3, sub4, sub5"
       ips:
        type: comma_delimited_list
        default: "ip1, ip2, ip3, ip4, ip5"

    resources:
      my_server:
        type: OS::Nova::Server
        properties:
          (...other properties)
          networks:
            repeat:
              for_each:
                %net%: { get_param: nets }
                %sub%: { get_param: subnets }
                %ip%: {get_param: ips}
              template:
                network: %net%
                subnet: %sub%
                fixed_ip: %ip%

I think it will be good to improve the 'repeat' function to support this user case. We can add the boolean flag 'permutations' to indicating whether do nested loops if 'for_each' has multiple key/values. Something like:

repeat:
  permutations: True(or False, default is True)
  for_each:
    ......
  template:
    ......

Blueprint information

Status:
Complete
Approver:
None
Priority:
Medium
Drafter:
huangtianhua
Direction:
Needs approval
Assignee:
huangtianhua
Definition:
Approved
Series goal:
Accepted for pike
Implementation:
Implemented
Milestone target:
milestone icon pike-3
Started by
huangtianhua
Completed by
huangtianhua

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/improve-repeat-function,n,z

Addressed by: https://review.openstack.org/251263
    Improve "repeat" function

Addressed by: https://review.openstack.org/473360
    Support 'nested_loop' for 'repeat' function

Addressed by: https://review.openstack.org/485418
    Add release note for repeat improvement

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.