blob: c94af4dd1f8f5bf6e368133ccccd7e813529b381 [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',
21 ]
22%}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030023{%- 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 Dmitrievcf5f43b2017-10-11 15:10:27 +030031 {%- if param_name in interface_allowed_params %}
32 {%- set _ = params.update({param_name: param}) %}
33 {%- endif %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030034 {%- endfor %}
35{%- endfor %}
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030036{%- set _ = params.update({'linux_network_interfaces':''}) %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030037{%- 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