11{ {- /* Helper templates */ -} }
2- { {- define " xrd.interfaces.multusCount" -} }
3- { {- $c := 0 } }
4- { {- range . } }
5- { {- if eq .type " multus" } }
6- { {- $c = add1 $c } }
7- { {- end } }
8- { {- end } }
9- { {- $c } }
10- { {- end -} }
112
123{ {- define " xrd.interfaces.anyMultus" -} }
134{ {- /*
@@ -22,6 +13,40 @@ or an empty string otherwise.
2213{ {- end } }
2314{ {- end -} }
2415
16+ { {- define " xrd.interfaces.anySRIOV" -} }
17+ { {- /*
18+ Returns a string equivalent to boolean true if there are any sriov interfaces,
19+ or an empty string otherwise.
20+ */ -} }
21+ { {- range (concat .Values.interfaces .Values.mgmtInterfaces) } }
22+ { {- if eq .type " sriov" } }
23+ 1
24+ { {- end } }
25+ { {- end } }
26+ { {- end -} }
27+
28+ { {- define " xrd.interfaces.anySRIOVData" -} }
29+ { {- /*
30+ Returns a string equivalent to boolean true if there are any sriov data interfaces,
31+ or an empty string otherwise.
32+ */ -} }
33+ { {- range .Values.interfaces } }
34+ { {- if eq .type " sriov" } }
35+ 1
36+ { {- end } }
37+ { {- end } }
38+ { {- end -} }
39+
40+ { {- define " xrd.interfaces.cniCount" -} }
41+ { {- $c := 0 } }
42+ { {- range .Values.interfaces } }
43+ { {- if or (eq .type " sriov" ) (eq .type " multus" ) } }
44+ { {- $c = add1 $c } }
45+ { {- end } }
46+ { {- end } }
47+ { {- $c } }
48+ { {- end -} }
49+
2550{ {- define " xrd.interfaces.checkDefaultCniCount" -} }
2651{ {- $c := 0 } }
2752{ {- range .Values.interfaces } }
@@ -41,7 +66,7 @@ or an empty string otherwise.
4166
4267{ {- define " xrd.interfaces.linuxflags" -} }
4368{ {- $flags := list } }
44- { {- $base := list " type" " config" " attachmentConfig" } }
69+ { {- $base := list " type" " config" " attachmentConfig" " resource " } }
4570{ {- range $k , $v := . -} }
4671 { {- if eq $k " snoopIpv4Address" } }
4772 { {- if $v } }
@@ -69,7 +94,7 @@ or an empty string otherwise.
6994 { {- end } }
7095 { {- $flags = append $flags (printf " xr_name=%s" $v ) } }
7196 { {- else if not (has $k $base ) } }
72- { {- fail (printf " %s may not be specified for defaultCni or multus interfaces" $k ) } }
97+ { {- fail (printf " %s may not be specified for defaultCni, multus or sriov interfaces" $k ) } }
7398 { {- end } }
7499{ {- end } }
75100{ {- join " ," $flags } }
@@ -86,16 +111,37 @@ or an empty string otherwise.
86111{ {- join " ," $flags } }
87112{ {- end -} }
88113
114+ { {- define " xrd.interfaces.sriovflags" -} }
115+ { {- $flags := list } }
116+ { {- $base := list " type" " config" " resource" } }
117+ { {- range $k , $v := . -} }
118+ { {- if not (has $k $base ) } }
119+ { {- fail (printf " %s may not be specified for sriov interfaces" $k ) } }
120+ { {- end } }
121+ { {- end } }
122+ { {- join " ," $flags } }
123+ { {- end -} }
124+
89125{ {- define " xrd.podNetworkAnnotations" -} }
90126{ {- $nets := list } }
91- { {- range $idx , $intf := concat .Values.interfaces .Values.mgmtInterfaces } }
127+ { {- $cniIndex := 0} }
128+ { {- range $intf := concat .Values.interfaces .Values.mgmtInterfaces } }
92129 { {- if eq $intf .type " multus" } }
93- { {- $netname := printf " %s-%d" (include " xrd.fullname" $) $idx } }
94- { {- $entry := dict " name" $netname } }
130+ { {- $netname := printf " %s-%d" (include " xrd.fullname" $) $cniIndex } }
131+ { {- $intfname := printf " net%d" $cniIndex } }
132+ { {- $entry := dict " name" $netname " interface" $intfname } }
95133 { {- if $intf .attachmentConfig } }
96134 { {- $entry = merge $entry $intf .attachmentConfig } }
97135 { {- end } }
98136 { {- $nets = append $nets $entry } }
137+ { {- $cniIndex = add1 $cniIndex } }
138+ { {- end } }
139+ { {- if eq $intf .type " sriov" } }
140+ { {- $netname := printf " %s-%d" (include " xrd.fullname" $) $cniIndex } }
141+ { {- $intfname := printf " net%d" $cniIndex } }
142+ { {- $entry := dict " name" $netname " interface" $intfname } }
143+ { {- $nets = append $nets $entry } }
144+ { {- $cniIndex = add1 $cniIndex } }
99145 { {- end } }
100146{ {- end } }
101147{ {- toPrettyJson $nets } }
0 commit comments