Initial commit
[ta/infra-ansible.git] / roles / sriov_nodes / templates / sriov.conf.j2
1 {%- set host_network_profiles_list = hosts[ansible_hostname]['network_profiles'] -%}
2 {%- set sriov_ifaces = [] -%}
3 {%- set trusted_ifaces = [] -%}
4 {%- set vf_counts = [] -%}
5 {%- if 'sriov_provider_networks' in network_profiles[host_network_profiles_list[0]] -%}
6     {%- set sriov_provider_networks = network_profiles[host_network_profiles_list[0]]['sriov_provider_networks'] -%}
7     {%- for net,net_info in sriov_provider_networks.iteritems() -%}
8         {%- if 'trusted' in net_info -%}
9             {%- set is_trusted = net_info['trusted'] -%}
10         {%- else -%}
11             {%- set is_trusted = False -%}
12         {%- endif -%}
13         {%- if 'vf_count' in net_info -%}
14             {%- set vf_count = net_info['vf_count'] -%}
15         {%- else -%}
16             {%- set vf_count = 0 -%}
17         {%- endif -%}
18         {%- for iface in net_info['interfaces'] -%}
19             {%- if sriov_ifaces.append(iface) -%}{%- endif -%}
20             {%- if is_trusted -%}
21                 {%- if trusted_ifaces.append(iface) -%}{%- endif -%}
22             {%- endif -%}
23             {%- if vf_count > 0 -%}
24                 {%- set count_info = iface ~ ':' ~ vf_count -%}
25                 {%- if vf_counts.append(count_info) -%}{%- endif -%}
26             {%- endif -%}
27         {%- endfor -%}
28     {%- endfor -%}
29 {%- endif -%}
30 {%- set offloaded_ifaces = [] -%}
31 {%- set trusted_offloaded_ifaces = [] -%}
32 {%- set vf_counts_offloaded = [] -%}
33 {%- if 'provider_network_interfaces' in network_profiles[host_network_profiles_list[0]] -%}
34     {%- set provider_network_interfaces = network_profiles[host_network_profiles_list[0]]['provider_network_interfaces'] -%}
35     {%- set bonding_interfaces = network_profiles[host_network_profiles_list[0]]['bonding_interfaces'] -%}
36     {%- for net,net_info in provider_network_interfaces.iteritems() -%}
37         {% if net_info['type'] == 'ovs-offload-sriov' -%}
38             {%- if 'trusted' in net_info -%}
39                 {%- set is_trusted = net_info['trusted'] -%}
40             {%- else -%}
41                 {%- set is_trusted = False -%}
42             {%- endif -%}
43             {%- if 'vf_count' in net_info -%}
44                 {%- set vf_count = net_info['vf_count'] -%}
45             {%- else -%}
46                 {%- set vf_count = 0 -%}
47             {%- endif -%}
48             {%- if net in bonding_interfaces -%}
49                 {%- for iface in bonding_interfaces[net] -%}
50                     {%- if sriov_ifaces.append(iface) -%}{%- endif -%}
51                     {%- if offloaded_ifaces.append(iface) -%}{%- endif -%}
52                     {%- if is_trusted -%}
53 {#-                     {%- if trusted_offloaded_ifaces.append(iface) -%}{%- endif -%} -#}
54                         {%- if trusted_ifaces.append(iface) -%}{%- endif -%}
55                     {%- endif -%}
56                     {%- if vf_count > 0 -%}
57                         {%- set count_info = iface ~ ':' ~ vf_count -%}
58 {#-                     {%- if vf_counts_offloaded.append(count_info) -%}{%- endif -%} -#}
59                         {%- if vf_counts.append(count_info) -%}{%- endif -%}
60                     {%- endif -%}
61                 {%- endfor -%}
62              {%- else -%}
63                 {%- if offloaded_ifaces.append(net) -%}{%- endif -%}
64                 {%- if sriov_ifaces.append(net) -%}{%- endif -%}
65                 {%- if is_trusted -%}
66                     {%- if trusted_offloaded_ifaces.append(net) -%}{%- endif -%}
67                     {%- if trusted_ifaces.append(net) -%}{%- endif -%}
68                 {%- endif -%}
69                 {%- if vf_count > 0 -%}
70                     {%- set count_info = net ~ ':' ~ vf_count -%}
71                     {%- if vf_counts_offloaded.append(count_info) -%}{%- endif -%}
72                     {%- if vf_counts.append(count_info) -%}{%- endif -%}
73                 {%- endif -%}
74              {% endif -%}
75         {%- endif -%}
76     {%- endfor -%}
77 {%- endif -%}
78 SRIOV_INTERFACES="{{sriov_ifaces | join(' ')}}"
79 SRIOV_TRUSTED_INTERFACES="{{trusted_ifaces | join(' ')}}"
80 SRIOV_VF_COUNTS="{{vf_counts | join(' ')}}"
81 SRIOV_INTERFACES_OFFLOADED="{{offloaded_ifaces | join(' ')}}"
82 {#- SRIOV_TRUSTED_INTERFACES_OFFLOADED="{{trusted_offloaded_ifaces | join(' ')}}" -#}
83 {#- SRIOV_VF_COUNTS_OFFLOADED="{{vf_counts_offloaded | join(' ')}}" -#}