Support repeat function without nested loops
We provide the 'repeat' intrinsic function in Kilo:
https:/
The 'repeat' function will do nested loops if 'for_each' has multiple key/values, something like this:
*******
parameters:
ports:
type: comma_delimited
label: ports
default: "80,443,8080"
protocols:
type: comma_delimited
label: protocols
default: "tcp,udp"
resources:
security_
type: OS::Neutron:
properties:
name: web_server_
rules:
repeat:
*******
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
default: "net1, net2, net3, net4, net5"
subnets:
type: comma_delimited
default: "sub1, sub2, sub3, sub4, sub5"
ips:
type: comma_delimited
default: "ip1, ip2, ip3, ip4, ip5"
resources:
my_server:
type: OS::Nova::Server
properties:
(...other properties)
networks:
repeat:
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:
- pike-3
- Started by
- huangtianhua
- Completed by
- huangtianhua
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
Improve "repeat" function
Addressed by: https:/
Support 'nested_loop' for 'repeat' function
Addressed by: https:/
Add release note for repeat improvement