blob: dbb35ebdd70404f3e7a037f6bcc93491271503ca [file] [log] [blame]
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +03001{#- 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 Dmitrievcf5f43b2017-10-11 15:10:27 +03008{%- 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 Butenkoaa2e3c52018-08-23 14:16:07 +030019 'external_address',
20 'external_network_netmask',
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030021 'dns_server01',
22 'dns_server02',
Dennis Dmitrieve56f3022018-03-22 20:14:59 +020023 'mtu',
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030024 ]
25%}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030026{%- 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 Dmitrievcf5f43b2017-10-11 15:10:27 +030034 {%- if param_name in interface_allowed_params %}
35 {%- set _ = params.update({param_name: param}) %}
36 {%- endif %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030037 {%- endfor %}
38{%- endfor %}
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030039{%- set _ = params.update({'linux_network_interfaces':''}) %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030040{%- 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