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

Conversation

kpbush30
Copy link

@kpbush30 kpbush30 commented Dec 9, 2024

Change Summary

Add platform match criteria for network_ports

Related Issue(s)

Fixes #4786

Component(s) name

arista.avd.eos_designs

Proposed changes

Add platform key to match to filter devices for network_ports

How to test

Run molecule scenario for eos_designs_uni_tests for NETWORK_PORTS_TESTS

molecule converge -s eos_designs_unit_tests -- --limit NETWORK_PORTS_TESTS

Checklist

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

Copy link

github-actions bot commented Dec 9, 2024

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4798
# Activate the virtual environment
source test-avd-pr-4798/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/kpbush30/avd.git@network_ports_4786#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/kpbush30/avd.git#/ansible_collections/arista/avd/,network_ports_4786 --force
# Optional: Install AVD examples
cd test-avd-pr-4798
ansible-playbook arista.avd.install_examples

@github-actions github-actions bot added state: CI Updated CI scenario have been updated in the PR state: Documentation role Updated role: eos_designs issue related to eos_designs role labels Dec 9, 2024
@kpbush30 kpbush30 marked this pull request as ready for review December 9, 2024 16:56
@kpbush30 kpbush30 requested review from a team as code owners December 9, 2024 16:56
@@ -20,6 +20,18 @@ 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.

@@ -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.

@github-actions github-actions bot added the state: conflict PR with conflict label Dec 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
role: eos_designs issue related to eos_designs role state: CI Updated CI scenario have been updated in the PR state: conflict PR with conflict state: Documentation role Updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat(eos_designs): Add platform match criteria for network_ports
3 participants