-
Notifications
You must be signed in to change notification settings - Fork 23
feat(discovery): add vlan over bond interface support #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,3 +224,45 @@ bond: | |
| true | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* Check if a link is a vlan interface */ -}} | ||
| {{- define "talm.discovered.is_vlan" -}} | ||
| {{- $linkName := . -}} | ||
| {{- $link := lookup "links" "" $linkName -}} | ||
| {{- if and $link (eq $link.spec.kind "vlan") -}} | ||
| true | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* Get parent link name by linkIndex */ -}} | ||
| {{- define "talm.discovered.parent_link_name" -}} | ||
| {{- $linkName := . -}} | ||
| {{- $link := lookup "links" "" $linkName -}} | ||
| {{- if and $link $link.spec.linkIndex -}} | ||
| {{- $parentIndex := $link.spec.linkIndex -}} | ||
| {{- range (lookup "links" "" "").items -}} | ||
| {{- if eq (int .spec.index) (int $parentIndex) -}} | ||
| {{- .metadata.id -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* Get vlan ID from link */ -}} | ||
| {{- define "talm.discovered.vlan_id" -}} | ||
| {{- $linkName := . -}} | ||
| {{- $link := lookup "links" "" $linkName -}} | ||
| {{- if and $link $link.spec.vlan -}} | ||
| {{- $link.spec.vlan.vlanID -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* Generate vlan configuration */ -}} | ||
| {{- define "talm.discovered.vlan_config" -}} | ||
| {{- $linkName := . -}} | ||
| {{- $link := lookup "links" "" $linkName -}} | ||
| {{- if and $link (eq $link.spec.kind "vlan") -}} | ||
| vlans: | ||
| - vlanId: {{ $link.spec.vlan.vlanID }} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
Comment on lines
+260
to
+268
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
talm.discovered.parent_link_namehelper iterates through all discovered links (range (lookup "links" "" "").items) to find the parent link bylinkIndex. While functional, this approach could become inefficient if the number of discovered links grows very large. For typical network configurations, this might not be an issue, but it's worth considering if a more direct lookup mechanism or an indexed map could be employed for better performance in environments with many interfaces.