Skip to content
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

Feat(eos_designs): Add platform match criteria for network_ports #4798

Open
wants to merge 16 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,24 @@ interface Ethernet17
no shutdown
switchport
!
interface Ethernet23
description PCs
no shutdown
switchport access vlan 100
switchport mode access
switchport
spanning-tree portfast
spanning-tree bpdufilter enable
!
interface Ethernet24
description PCs
no shutdown
switchport access vlan 100
switchport mode access
switchport
spanning-tree portfast
spanning-tree bpdufilter enable
!
interface Ethernet51
no shutdown
channel-group 43 mode active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,24 @@ interface Ethernet14
no shutdown
switchport
!
interface Ethernet47
description PCs
no shutdown
switchport access vlan 100
switchport mode access
switchport
spanning-tree portfast
spanning-tree bpdufilter enable
!
interface Ethernet48
description PCs
no shutdown
switchport access vlan 100
switchport mode access
switchport
spanning-tree portfast
spanning-tree bpdufilter enable
!
interface Ethernet51
shutdown
switchport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,30 @@ ethernet_interfaces:
channel_group:
id: 43
mode: active
- name: Ethernet23
peer: PCs
peer_type: network_port
port_profile: pc
description: PCs
shutdown: false
switchport:
enabled: true
mode: access
access_vlan: 100
spanning_tree_portfast: edge
spanning_tree_bpdufilter: enabled
- name: Ethernet24
peer: PCs
peer_type: network_port
port_profile: pc
description: PCs
shutdown: false
switchport:
enabled: true
mode: access
access_vlan: 100
spanning_tree_portfast: edge
spanning_tree_bpdufilter: enabled
mlag_configuration:
domain_id: mlag
local_interface: Vlan4094
Expand All @@ -833,3 +857,5 @@ monitor_sessions:
destinations:
- Ethernet17
encapsulation_gre_metadata_tx: true
metadata:
platform: 720XPM-24Y6
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,30 @@ ethernet_interfaces:
shutdown: true
switchport:
enabled: true
- name: Ethernet47
peer: PCs
peer_type: network_port
port_profile: pc
description: PCs
shutdown: false
switchport:
enabled: true
mode: access
access_vlan: 100
spanning_tree_portfast: edge
spanning_tree_bpdufilter: enabled
- name: Ethernet48
peer: PCs
peer_type: network_port
port_profile: pc
description: PCs
shutdown: false
switchport:
enabled: true
mode: access
access_vlan: 100
spanning_tree_portfast: edge
spanning_tree_bpdufilter: enabled
mlag_configuration:
domain_id: mlag
local_interface: Vlan4094
Expand All @@ -760,3 +784,5 @@ mlag_configuration:
reload_delay_non_mlag: '330'
ip_igmp_snooping:
globally_enabled: true
metadata:
platform: 720XPM-48Y6
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@ network_ports:
channel_id: 43
mode: "active"

# The next two switches are targeted using a like regex filtering on correct platform type
# Test regex and platform match criteria
- switches:
- network-ports-tests.*
laxmikantchintakindi marked this conversation as resolved.
Show resolved Hide resolved
switch_ports:
- Ethernet47-48
platforms:
- 720XPM-48Y6
profile: pc
endpoint: PCs

# Test only platform match
- switch_ports:
- Ethernet23-24
platforms:
- 720XPM-24Y6
profile: pc
endpoint: PCs

servers:
- name: CONNECTED_ENDPOINT_OVERWRITING_NETWORK_PORT
adapters:
Expand Down Expand Up @@ -171,7 +190,23 @@ l2leaf:
nodes:
- name: network-ports-tests.1
id: 1
platform: 720XPM-48Y6
- name: network-ports-tests-2
filter:
only_vlans_in_use: true
id: 2
platform: 720XPM-24Y6

# Used for platform filtering tests
custom_platform_settings:
- platforms:
- 720XPM-48Y6
- 720XPM-24Y6
feature_support:
poe: true
queue_monitor_length_notify: false
reload_delay:
mlag: 300
non_mlag: 330
trident_forwarding_table_partition: flexible exact-match 16000 l2-shared 18000 l3-shared
22000

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions python-avd/pyavd/_eos_designs/schema/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ keys:
The regular expression must match the full hostname.
items:
type: str
platforms:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a description on the network_ports stating that when switches and platforms are both set, then only devices matching both criteria will be configured.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added clarification in schema docs and in markdown above clarifying match criteria expectations.

type: list
kpbush30 marked this conversation as resolved.
Show resolved Hide resolved
description: |
Matching the platform type of one or more switches, to match full platform names, create a custom platform in `platform_settings`.
kpbush30 marked this conversation as resolved.
Show resolved Hide resolved
For example, `720XP-48Y6` would require a custom platform type:

platforms:
- 720XP
- 720XP-48Y6
items:
type: str
switch_ports:
type: list
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def _filtered_network_ports(self: AvdStructuredConfigConnectedEndpoints) -> list
for index, network_port in enumerate(self.inputs.network_ports):
network_port._context = f"network_ports[{index}]"
network_port_settings = self.shared_utils.get_merged_adapter_settings(network_port)
if not self._match_regexes(network_port_settings.switches, self.shared_utils.hostname):
if network_port_settings.switches and not self._match_regexes(network_port_settings.switches, self.shared_utils.hostname):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is changing the behavior. In the current implementation, if switches is not set, then no network_port are configured on any device. The change, if neither switches, nor platforms are set would configure the network_ports on ALL devices.

you would need an extra if to make sure that either switches or platforms are set + add a test case with network_ports without switches not platforms set to validate the behavior

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed behavior to ensure match criteria is required, added test to ensure configuration is not generated if missing both switch hostname and platform match criteria.

continue
if network_port_settings.platforms and self.shared_utils.platform not in network_port_settings.platforms:
continue

filtered_network_ports.append(network_port_settings)
Expand Down
Loading