Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 1 | {#- Collect interface roles and params into the following dict: |
| 2 | # interface_role: # filename that will be included |
| 3 | # interface_name: # interface (eth0) |
| 4 | # interface_param1: value # optional parameters or empty dict |
| 5 | # interface_param2: value |
| 6 | # ... |
| 7 | #} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 8 | {%- set interface_allowed_params = [ |
| 9 | 'deploy_address', |
| 10 | 'deploy_network_netmask', |
| 11 | 'deploy_network_gateway', |
| 12 | 'single_address', |
| 13 | 'control_vlan', |
| 14 | 'control_network_netmask', |
| 15 | 'tenant_vlan', |
| 16 | 'tenant_address', |
| 17 | 'tenant_network_netmask', |
| 18 | 'tenant_network_gateway', |
| 19 | 'dns_server01', |
| 20 | 'dns_server02', |
| 21 | ] |
| 22 | %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 23 | {%- set interface_roles = {} %} |
| 24 | {%- for interface_name, interface in node['interfaces'].items() %} |
| 25 | {%- if interface['role'] not in interface_roles %} |
| 26 | {%- set _ = interface_roles.update({interface['role']: {}}) %} |
| 27 | {%- endif %} |
| 28 | {%- set _ = interface_roles[interface['role']].update({interface_name: {}}) %} |
| 29 | {%- for param_name, param in interface.items() %} |
| 30 | {%- set _ = interface_roles[interface['role']][interface_name].update({param_name: param}) %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 31 | {%- if param_name in interface_allowed_params %} |
| 32 | {%- set _ = params.update({param_name: param}) %} |
| 33 | {%- endif %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 34 | {%- endfor %} |
| 35 | {%- endfor %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 36 | {%- set _ = params.update({'linux_network_interfaces':''}) %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 37 | {%- for interfaces_role, interfaces in interface_roles.items() %} |
| 38 | {%- import ("{# interfaces #}/" + interfaces_role) as interface with context %} |
| 39 | {%- set _ = params.update({'linux_network_interfaces': params['linux_network_interfaces'] + interface|string }) %} |
| 40 | {%- endfor %} |
| 41 | - environment.{{ cookiecutter._env_name }}.linux_network_interface |