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

Refactor(eos_designs): Refactor eos_designs structured_config code for router_path_selection.py #5002

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

laxmikantchintakindi
Copy link
Contributor

@laxmikantchintakindi laxmikantchintakindi commented Feb 10, 2025

Change Summary

Refactor eos_designs structured_config code for router_path_selection.py.

Related Issue(s)

Fixes #

Component(s) name

arista.avd.eos_designs

Proposed changes

Refactor eos_designs structured_config code for router_path_selection.py.

How to test

Checklist

User Checklist

  • N/A

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

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-5002
# Activate the virtual environment
source test-avd-pr-5002/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/laxmikantchintakindi/avd.git@refactor/router-path-selection#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/laxmikantchintakindi/avd.git#/ansible_collections/arista/avd/,refactor/router-path-selection --force
# Optional: Install AVD examples
cd test-avd-pr-5002
ansible-playbook arista.avd.install_examples

@@ -19,15 +20,13 @@ class RouterPathSelectionMixin(Protocol):
Class should only be used as Mixin to a AvdStructuredConfig class.
"""

@cached_property
def router_path_selection(self: AvdStructuredConfigNetworkServicesProtocol) -> dict | None:
@structured_config_contributor
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update the overlay as well in the same PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 48 to 55
lb_policy = EosCliConfigGen.RouterPathSelection.LoadBalancePoliciesItem()
lb_policy._update(
name=get(match["load_balance_policy"], "name", None),
lowest_hop_count=get(match["load_balance_policy"], "lowest_hop_count", None),
jitter=get(match["load_balance_policy"], "jitter", None),
latency=get(match["load_balance_policy"], "latency", None),
loss_rate=get(match["load_balance_policy"], "loss_rate", None),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lb_policy = EosCliConfigGen.RouterPathSelection.LoadBalancePoliciesItem()
lb_policy._update(
name=get(match["load_balance_policy"], "name", None),
lowest_hop_count=get(match["load_balance_policy"], "lowest_hop_count", None),
jitter=get(match["load_balance_policy"], "jitter", None),
latency=get(match["load_balance_policy"], "latency", None),
loss_rate=get(match["load_balance_policy"], "loss_rate", None),
)
lb_policy = EosCliConfigGen.RouterPathSelection.LoadBalancePoliciesItem(
name=get(match["load_balance_policy"], "name", None),
lowest_hop_count=get(match["load_balance_policy"], "lowest_hop_count", None),
jitter=get(match["load_balance_policy"], "jitter", None),
latency=get(match["load_balance_policy"], "latency", None),
loss_rate=get(match["load_balance_policy"], "loss_rate", None),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also am not sure we should provide the static keys and values. Check if we can update the the match["load_balance_policy"] as object instead of dict from the helper functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied suggestion in commit.

@github-actions github-actions bot added state: CI Updated CI scenario have been updated in the PR and removed state: CI Updated CI scenario have been updated in the PR labels Feb 18, 2025
@laxmikantchintakindi laxmikantchintakindi force-pushed the refactor/router-path-selection branch from 0c85f19 to 751ba2d Compare February 19, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants