[fuel] net_macros: Allow interface proto override
[pharos.git] / config / installers / fuel / net_macros.j2
1 ##############################################################################
2 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 ##############################################################################
8 {%- macro linux_network_interfaces_nic(nics, proto = 'manual') -%}
9 {%- for nic in nics %}
10         {{ nic }}:
11           enabled: true
12           type: eth
13           proto: {{ proto }}
14           mtu: ${_param:interface_mtu}
15           name: {{ nic }}
16           noifupdown: true
17 {%- endfor %}
18 {%- endmacro -%}
19
20 {%- macro linux_network_interfaces_vlan(vlans, proto = 'manual') -%}
21 {%- for vlan in vlans %}
22     {%- if vlan | int > 0 %}
23         {{ vlans[vlan] }}.{{ vlan }}:
24           enabled: true
25           proto: {{ proto }}
26           mtu: ${_param:interface_mtu}
27           type: vlan
28           name: {{ vlans[vlan] }}.{{ vlan }}
29           use_interfaces:
30             - {{ vlans[vlan] }}
31     {%- endif %}
32 {%- endfor %}
33 {%- endmacro -%}
34
35 {%- macro interface_str(nic, vlan = 0) -%}
36     {{ nic }}{% if vlan | int > 0 %}.{{ vlan }}{% endif %}
37 {%- endmacro -%}
38
39 {%- macro vpp_interface_str(speed, pci_addr, driver = '') -%}
40     {%- set p = pci_addr.replace('.', ':').split(':') -%}
41     {%- set s = 'Ethernet%d/%d/%d' | format(p[-3] | int(0, 16),
42                                             p[-2] | int(0, 16),
43                                             p[-1] | int(0, 16)) -%}
44     {%- if 'vfio' in driver -%}
45     VirtualFunction{{ s }}
46     {%- else -%}
47     {% if '40g' in speed %}Forty{% elif '10g' in speed %}Ten{% endif %}Gigabit{{ s }}
48     {%- endif -%}
49 {%- endmacro -%}