Skip to content

Commit 903a8ed

Browse files
authored
Merge branch 'devel' into add_mpls_tunnel_termination
2 parents ad6a3c4 + e57a458 commit 903a8ed

File tree

13 files changed

+299
-51
lines changed

13 files changed

+299
-51
lines changed

Diff for: ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests-2.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,11 @@ interface Ethernet17
597597
no shutdown
598598
switchport
599599
!
600+
interface Ethernet24
601+
description Matched on only 24 port platform
602+
no shutdown
603+
switchport
604+
!
600605
interface Ethernet51
601606
no shutdown
602607
channel-group 43 mode active

Diff for: ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/network-ports-tests.1.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,11 @@ interface Ethernet14
544544
no shutdown
545545
switchport
546546
!
547+
interface Ethernet48
548+
description Matched on all hostnames and 48 port platform
549+
no shutdown
550+
switchport
551+
!
547552
interface Ethernet51
548553
shutdown
549554
switchport

Diff for: ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests-2.yml

+7
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,12 @@ ethernet_interfaces:
727727
id: 43
728728
mode: active
729729
peer_type: network_port
730+
- name: Ethernet24
731+
description: Matched on only 24 port platform
732+
shutdown: false
733+
peer_type: network_port
734+
switchport:
735+
enabled: true
730736
hostname: network-ports-tests-2
731737
ip_igmp_snooping:
732738
globally_enabled: true
@@ -736,6 +742,7 @@ management_api_http:
736742
enable_vrfs:
737743
- name: MGMT
738744
metadata:
745+
platform: 720XPM-24Y6
739746
fabric_name: EOS_DESIGNS_UNIT_TESTS
740747
mlag_configuration:
741748
domain_id: mlag

Diff for: ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/network-ports-tests.1.yml

+7
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ ethernet_interfaces:
697697
peer_type: network_port
698698
switchport:
699699
enabled: true
700+
- name: Ethernet48
701+
description: Matched on all hostnames and 48 port platform
702+
shutdown: false
703+
peer_type: network_port
704+
switchport:
705+
enabled: true
700706
hostname: network-ports-tests.1
701707
ip_igmp_snooping:
702708
globally_enabled: true
@@ -706,6 +712,7 @@ management_api_http:
706712
enable_vrfs:
707713
- name: MGMT
708714
metadata:
715+
platform: 720XPM-48Y6
709716
fabric_name: EOS_DESIGNS_UNIT_TESTS
710717
mlag_configuration:
711718
domain_id: mlag

Diff for: ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/NETWORK_PORTS_TESTS.yml

+47
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,37 @@ network_ports:
141141
channel_id: 43
142142
mode: "active"
143143

144+
# Tests for issue #4786
145+
# Test regex match all switches and specific platform match criteria.
146+
- switches:
147+
- network-ports-tests.*
148+
platforms:
149+
- 720XPM-48Y6
150+
switch_ports:
151+
- Ethernet48
152+
description: Matched on all hostnames and 48 port platform
153+
154+
# Test only platform match.
155+
- platforms:
156+
- 720\w+-24Y6
157+
switch_ports:
158+
- Ethernet24
159+
description: Matched on only 24 port platform
160+
161+
# Test criteria must match both hostname/platform.
162+
- switches:
163+
- network-ports-no-match
164+
platforms:
165+
- 720XPM-48Y6
166+
switch_ports:
167+
- Ethernet49
168+
description: Should not match hostname and platform
169+
170+
# Test no match criteria
171+
- switch_ports:
172+
- Ethernet25
173+
description: No criteria, no config
174+
144175
servers:
145176
- name: CONNECTED_ENDPOINT_OVERWRITING_NETWORK_PORT
146177
adapters:
@@ -171,7 +202,23 @@ l2leaf:
171202
nodes:
172203
- name: network-ports-tests.1
173204
id: 1
205+
platform: 720XPM-48Y6
174206
- name: network-ports-tests-2
175207
filter:
176208
only_vlans_in_use: true
177209
id: 2
210+
platform: 720XPM-24Y6
211+
212+
# Used for platform filtering tests
213+
custom_platform_settings:
214+
- platforms:
215+
- 720XPM-48Y6
216+
- 720XPM-24Y6
217+
feature_support:
218+
poe: true
219+
queue_monitor_length_notify: false
220+
reload_delay:
221+
mlag: 300
222+
non_mlag: 330
223+
trident_forwarding_table_partition: flexible exact-match 16000 l2-shared 18000 l3-shared
224+
22000

Diff for: ansible_collections/arista/avd/roles/eos_designs/docs/input-variables.md

+50
Original file line numberDiff line numberDiff line change
@@ -1161,12 +1161,62 @@ roles/eos_designs/docs/tables/default-connected-endpoints-description.md
11611161
The `network_ports` data model is intended to be used with `port_profiles` and `parent_profiles` to keep the configuration generic and compact,
11621162
but all features and keys supported under `connected_endpoints.adapters` are also supported directly under `network_ports`.
11631163

1164+
To filter what switches to configure, match on a switch full hostname or platform type using regex patterns. When both criteria are used together, the switch must match both in order to generate the assigned port configuration.
1165+
11641166
All ranges defined under `switch_ports` will be expanded to individual port configuration which leads to a some behavioral differences to `connected_endpoints`:
11651167

11661168
- By default each port will be configured in a port-channel with one member when leveraging automatic channel-id generation.
11671169
To configure multiple ports as member of the same port-channel set the channel-id key (see the example below).
11681170
- Inconsistent configurations when used with `short_esi: auto` or `designated_forwarder_algorithm: auto`, since those rely on information from multiple switches and interfaces.
11691171

1172+
??? example "Example using match criteria"
1173+
1174+
```yaml
1175+
# Port Profiles
1176+
# Common settings inherited to network_ports
1177+
port_profiles:
1178+
- profile: common
1179+
mode: access
1180+
vlans: "999"
1181+
spanning_tree_portfast: edge
1182+
spanning_tree_bpdufilter: enabled
1183+
1184+
# Network Ports
1185+
# Switches are matched with regex matching the full hostname and platform type.
1186+
network_ports:
1187+
- switches:
1188+
- network-ports-[est]{5}-.*
1189+
platforms:
1190+
- 720XPM-48Y6
1191+
switch_ports:
1192+
- Ethernet1-48
1193+
profile: common
1194+
1195+
# Switches are matched on platform type, regardless of hostname.
1196+
- platforms:
1197+
- 720XPM-24Y6
1198+
switch_ports:
1199+
- Ethernet1-24
1200+
profile: common
1201+
1202+
# Custom Platform Settings
1203+
# Copied default 720XP platform settings, adding more specific platform names for match.
1204+
# These platform types can be assigned to devices as part of nodes/node_group settings.
1205+
custom_platform_settings:
1206+
- platforms:
1207+
- 720XPM-48Y6
1208+
- 720XPM-24Y6
1209+
feature_support:
1210+
poe: true
1211+
queue_monitor_length_notify: false
1212+
reload_delay:
1213+
mlag: 300
1214+
non_mlag: 330
1215+
trident_forwarding_table_partition: flexible exact-match 16000 l2-shared 18000 l3-shared
1216+
22000
1217+
1218+
```
1219+
11701220
??? example "Example using network ports and profiles"
11711221

11721222
```yaml

Diff for: ansible_collections/arista/avd/roles/eos_designs/docs/tables/network-ports.md

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: python-avd/pyavd/_eos_designs/schema/__init__.py

+43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: python-avd/pyavd/_eos_designs/schema/schema_fragments/network_ports.schema.yml

+16
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,29 @@ keys:
1313
$ref: "eos_designs#/$defs/adapter_config"
1414
# These keys will take precedence over $ref
1515
keys:
16+
# TODO: AVD 6.0.0 add min_length: 1 for switches
1617
switches:
1718
type: list
1819
description: |
1920
Regex matching the full hostname of one or more switches.
2021
The regular expression must match the full hostname.
2122
items:
2223
type: str
24+
platforms:
25+
type: list
26+
min_length: 1
27+
description: |-
28+
Regex matching the full platform name of one or more switches. If used in combination with switch hostname matching, both criteria must match for configuration.
29+
If you need to add custom platforms to match specific port quantities, create them under `custom_platform_settings`. Entries under `custom_platform_settings` should
30+
match the platform match criteria.
31+
32+
For example, `720XP-48Y6` would require a custom platform type:
33+
34+
platforms:
35+
- 720XP
36+
- 720XP-48Y6
37+
items:
38+
type: str
2339
switch_ports:
2440
type: list
2541
description: |

Diff for: python-avd/pyavd/_eos_designs/structured_config/connected_endpoints/utils.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ def _filtered_network_ports(self: AvdStructuredConfigConnectedEndpoints) -> list
7272
for index, network_port in enumerate(self.inputs.network_ports):
7373
network_port._context = f"network_ports[{index}]"
7474
network_port_settings = self.shared_utils.get_merged_adapter_settings(network_port)
75-
if not self._match_regexes(network_port_settings.switches, self.shared_utils.hostname):
75+
76+
if not network_port_settings.switches and not network_port_settings.platforms:
77+
continue
78+
if network_port_settings.switches and not self._match_regexes(network_port_settings.switches, self.shared_utils.hostname):
79+
continue
80+
if network_port_settings.platforms and not self._match_regexes(network_port_settings.platforms, self.shared_utils.platform):
7681
continue
7782

7883
filtered_network_ports.append(network_port_settings)
@@ -83,9 +88,9 @@ def _match_regexes(self: AvdStructuredConfigConnectedEndpoints, regexes: list, v
8388
"""
8489
Match a list of regexes with the supplied value.
8590
86-
Regex must match the full value to pass, so regex is wrapped in ^$.
91+
Regex must match the full value to pass.
8792
"""
88-
return any(re.match(rf"^{regex}$", value) for regex in regexes)
93+
return any(re.fullmatch(regex, value) for regex in regexes)
8994

9095
def _get_short_esi(
9196
self: AvdStructuredConfigConnectedEndpoints,

0 commit comments

Comments
 (0)