File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,11 +76,32 @@ machine:
7676 {{- $existingInterfacesConfiguration | nindent 4 }}
7777 {{- else }}
7878 {{- $defaultLinkName := include " talm.discovered.default_link_name_by_gateway" . }}
79- - interface: {{ $defaultLinkName }}
80- {{- $bondConfig := include " talm.discovered.bond_config" $defaultLinkName }}
79+ {{- $isVlan := include " talm.discovered.is_vlan" $defaultLinkName }}
80+ {{- $parentLinkName := " " }}
81+ {{- if $isVlan }}
82+ {{- $parentLinkName = include " talm.discovered.parent_link_name" $defaultLinkName }}
83+ {{- end }}
84+ {{- $interfaceName := $defaultLinkName }}
85+ {{- if and $isVlan $parentLinkName }}
86+ {{- $interfaceName = $parentLinkName }}
87+ {{- end }}
88+ - interface: {{ $interfaceName }}
89+ {{- $bondConfig := include " talm.discovered.bond_config" $interfaceName }}
8190 {{- if $bondConfig }}
8291 {{- $bondConfig | nindent 6 }}
8392 {{- end }}
93+ {{- if $isVlan }}
94+ vlans:
95+ - vlanId: {{ include " talm.discovered.vlan_id" $defaultLinkName }}
96+ addresses: {{ include " talm.discovered.default_addresses_by_gateway" . }}
97+ routes:
98+ - network: 0.0.0.0 /0
99+ gateway: {{ include " talm.discovered.default_gateway" . }}
100+ {{- if and .Values.floatingIP (eq .MachineType " controlplane" ) }}
101+ vip:
102+ ip: {{ .Values.floatingIP }}
103+ {{- end }}
104+ {{- else }}
84105 addresses: {{ include " talm.discovered.default_addresses_by_gateway" . }}
85106 routes:
86107 - network: 0.0.0.0 /0
@@ -89,6 +110,7 @@ machine:
89110 vip:
90111 ip: {{ .Values.floatingIP }}
91112 {{- end }}
113+ {{- end }}
92114 {{- end }}
93115
94116cluster:
Original file line number Diff line number Diff line change @@ -22,11 +22,32 @@ machine:
2222 {{- $existingInterfacesConfiguration | nindent 4 }}
2323 {{- else }}
2424 {{- $defaultLinkName := include " talm.discovered.default_link_name_by_gateway" . }}
25- - interface: {{ $defaultLinkName }}
26- {{- $bondConfig := include " talm.discovered.bond_config" $defaultLinkName }}
25+ {{- $isVlan := include " talm.discovered.is_vlan" $defaultLinkName }}
26+ {{- $parentLinkName := " " }}
27+ {{- if $isVlan }}
28+ {{- $parentLinkName = include " talm.discovered.parent_link_name" $defaultLinkName }}
29+ {{- end }}
30+ {{- $interfaceName := $defaultLinkName }}
31+ {{- if and $isVlan $parentLinkName }}
32+ {{- $interfaceName = $parentLinkName }}
33+ {{- end }}
34+ - interface: {{ $interfaceName }}
35+ {{- $bondConfig := include " talm.discovered.bond_config" $interfaceName }}
2736 {{- if $bondConfig }}
2837 {{- $bondConfig | nindent 6 }}
2938 {{- end }}
39+ {{- if $isVlan }}
40+ vlans:
41+ - vlanId: {{ include " talm.discovered.vlan_id" $defaultLinkName }}
42+ addresses: {{ include " talm.discovered.default_addresses_by_gateway" . }}
43+ routes:
44+ - network: 0.0.0.0 /0
45+ gateway: {{ include " talm.discovered.default_gateway" . }}
46+ {{- if and .Values.floatingIP (eq .MachineType " controlplane" ) }}
47+ vip:
48+ ip: {{ .Values.floatingIP }}
49+ {{- end }}
50+ {{- else }}
3051 addresses: {{ include " talm.discovered.default_addresses_by_gateway" . }}
3152 routes:
3253 - network: 0.0.0.0 /0
@@ -35,6 +56,7 @@ machine:
3556 vip:
3657 ip: {{ .Values.floatingIP }}
3758 {{- end }}
59+ {{- end }}
3860 {{- end }}
3961
4062cluster:
Original file line number Diff line number Diff line change @@ -224,3 +224,45 @@ bond:
224224true
225225{{- end -}}
226226{{- end -}}
227+
228+ {{- /* Check if a link is a vlan interface */ -}}
229+ {{- define " talm.discovered.is_vlan" -}}
230+ {{- $linkName := . -}}
231+ {{- $link := lookup " links" " " $linkName -}}
232+ {{- if and $link (eq $link .spec.kind " vlan" ) -}}
233+ true
234+ {{- end -}}
235+ {{- end -}}
236+
237+ {{- /* Get parent link name by linkIndex */ -}}
238+ {{- define " talm.discovered.parent_link_name" -}}
239+ {{- $linkName := . -}}
240+ {{- $link := lookup " links" " " $linkName -}}
241+ {{- if and $link $link .spec.linkIndex -}}
242+ {{- $parentIndex := $link .spec.linkIndex -}}
243+ {{- range (lookup " links" " " " " ).items -}}
244+ {{- if eq (int .spec.index ) (int $parentIndex ) -}}
245+ {{- .metadata.id -}}
246+ {{- end -}}
247+ {{- end -}}
248+ {{- end -}}
249+ {{- end -}}
250+
251+ {{- /* Get vlan ID from link */ -}}
252+ {{- define " talm.discovered.vlan_id" -}}
253+ {{- $linkName := . -}}
254+ {{- $link := lookup " links" " " $linkName -}}
255+ {{- if and $link $link .spec.vlan -}}
256+ {{- $link .spec.vlan.vlanID -}}
257+ {{- end -}}
258+ {{- end -}}
259+
260+ {{- /* Generate vlan configuration */ -}}
261+ {{- define " talm.discovered.vlan_config" -}}
262+ {{- $linkName := . -}}
263+ {{- $link := lookup " links" " " $linkName -}}
264+ {{- if and $link (eq $link .spec.kind " vlan" ) -}}
265+ vlans:
266+ - vlanId: {{ $link .spec.vlan.vlanID }}
267+ {{- end -}}
268+ {{- end -}}
You can’t perform that action at this time.
0 commit comments