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', |
Oleksii Butenko | aa2e3c5 | 2018-08-23 14:16:07 +0300 | [diff] [blame^] | 19 | 'external_address', |
| 20 | 'external_network_netmask', |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 21 | 'dns_server01', |
| 22 | 'dns_server02', |
Dennis Dmitriev | e56f302 | 2018-03-22 20:14:59 +0200 | [diff] [blame] | 23 | 'mtu', |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 24 | ] |
| 25 | %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 26 | {%- set interface_roles = {} %} |
| 27 | {%- for interface_name, interface in node['interfaces'].items() %} |
| 28 | {%- if interface['role'] not in interface_roles %} |
| 29 | {%- set _ = interface_roles.update({interface['role']: {}}) %} |
| 30 | {%- endif %} |
| 31 | {%- set _ = interface_roles[interface['role']].update({interface_name: {}}) %} |
| 32 | {%- for param_name, param in interface.items() %} |
| 33 | {%- set _ = interface_roles[interface['role']][interface_name].update({param_name: param}) %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 34 | {%- if param_name in interface_allowed_params %} |
| 35 | {%- set _ = params.update({param_name: param}) %} |
| 36 | {%- endif %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 37 | {%- endfor %} |
| 38 | {%- endfor %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 39 | {%- set _ = params.update({'linux_network_interfaces':''}) %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 40 | {%- for interfaces_role, interfaces in interface_roles.items() %} |
| 41 | {%- import ("{# interfaces #}/" + interfaces_role) as interface with context %} |
| 42 | {%- set _ = params.update({'linux_network_interfaces': params['linux_network_interfaces'] + interface|string }) %} |
| 43 | {%- endfor %} |
| 44 | - environment.{{ cookiecutter._env_name }}.linux_network_interface |