blob: 85de14febbfe9fe395155b7f59a39baaa19cd7a0 [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',
19 'dns_server01',
20 'dns_server02',
Dennis Dmitrieve56f3022018-03-22 20:14:59 +020021 'mtu',
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030022 ]
23%}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030024{%- set interface_roles = {} %}
25{%- for interface_name, interface in node['interfaces'].items() %}
26 {%- if interface['role'] not in interface_roles %}
27 {%- set _ = interface_roles.update({interface['role']: {}}) %}
28 {%- endif %}
29 {%- set _ = interface_roles[interface['role']].update({interface_name: {}}) %}
30 {%- for param_name, param in interface.items() %}
31 {%- set _ = interface_roles[interface['role']][interface_name].update({param_name: param}) %}
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030032 {%- if param_name in interface_allowed_params %}
33 {%- set _ = params.update({param_name: param}) %}
34 {%- endif %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030035 {%- endfor %}
36{%- endfor %}
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030037{%- set _ = params.update({'linux_network_interfaces':''}) %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030038{%- for interfaces_role, interfaces in interface_roles.items() %}
39 {%- import ("{# interfaces #}/" + interfaces_role) as interface with context %}
40 {%- set _ = params.update({'linux_network_interfaces': params['linux_network_interfaces'] + interface|string }) %}
41{%- endfor %}
42 - environment.{{ cookiecutter._env_name }}.linux_network_interface