Skip to content

Refactor(eos_designs): Optimized the render of static routes structure config#6722

Open
MaheshGSLAB wants to merge 9 commits intoaristanetworks:develfrom
MaheshGSLAB:static-routes-refactor
Open

Refactor(eos_designs): Optimized the render of static routes structure config#6722
MaheshGSLAB wants to merge 9 commits intoaristanetworks:develfrom
MaheshGSLAB:static-routes-refactor

Conversation

@MaheshGSLAB
Copy link
Copy Markdown
Contributor

Change Summary

Optimized the render of static routes structure config

Related Issue(s)

Fixes #

Component(s) name

arista.avd.eos_designs

Proposed changes

Add helper method and run_once decorator to optimize the render of static_routes structure config

How to test

CI should be green without structure config and cfg changes

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)

@MaheshGSLAB MaheshGSLAB self-assigned this Mar 19, 2026
@github-actions
Copy link
Copy Markdown

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-6722
# Activate the virtual environment
source test-avd-pr-6722/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/MaheshGSLAB/avd.git@static-routes-refactor#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
python -m ansible.cli.galaxy collection install git+https://github.com/MaheshGSLAB/avd.git#/ansible_collections/arista/avd/,static-routes-refactor --force
cd test-avd-pr-6722
# Run your playbook using `python -m ansible.cli.playbook path/to/playbook.yml ...`

You can also test this PR using AVD playground:

  • Rebase your branch to makes sure it is up-to-date and has latest lab topologies for example inventories
  • Authenticate on labs.arista.com. Use your email! Not login.
  • Start the playground
  • In the lab selector UI pick "I want to use a specific AVD fork"
  • Enter following parameters:
GitHub org: MaheshGSLAB
Repository name: avd
Branch: static-routes-refactor
  • Select an example inventory to test the PR
  • Once the AVD Playground setup will be finished, type make start and test anything once the lab is up

Co-authored-by: Shivani-gslab <145646625+Shivani-gslab@users.noreply.github.com>


def append_gateway_routes(
routes_list: EosCliConfigGen.StaticRoutes | EosCliConfigGen.Ipv6StaticRoutes,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nayve lets add some override to prevent an IPv4 route to be added to an ipv6 list?'

@gmuloc
Copy link
Copy Markdown
Contributor

gmuloc commented Mar 20, 2026

@MaheshGSLAB we have merged #6729 which will give you access to stuctured_config inside structured_config_utils so that will simplify your PR a lot.

@github-actions github-actions bot added the state: conflict PR with conflict label Mar 20, 2026
@github-actions
Copy link
Copy Markdown

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

@github-actions github-actions bot removed the state: conflict PR with conflict label Mar 23, 2026
@github-actions
Copy link
Copy Markdown

Conflicts have been resolved. A maintainer will review the pull request shortly.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.20%. Comparing base (19adfcb) to head (c6e413b).
⚠️ Report is 5 commits behind head on devel.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            devel    #6722   +/-   ##
=======================================
  Coverage   87.20%   87.20%           
=======================================
  Files         350      350           
  Lines       19152    19158    +6     
  Branches     3585     3579    -6     
=======================================
+ Hits        16701    16707    +6     
  Misses       1887     1887           
  Partials      564      564           
Files with missing lines Coverage Δ
...vd/_eos_designs/structured_config/base/__init__.py 97.03% <100.00%> (-0.08%) ⬇️
...ns/structured_config/inband_management/__init__.py 95.16% <100.00%> (-0.16%) ⬇️
...ured_config/network_services/ipv6_static_routes.py 100.00% <100.00%> (ø)
...tructured_config/network_services/static_routes.py 100.00% <100.00%> (ø)
...signs/structured_config/structured_config_utils.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link
Copy Markdown

@Vibhu-gslab Vibhu-gslab marked this pull request as ready for review March 26, 2026 07:42
@Vibhu-gslab Vibhu-gslab requested review from a team as code owners March 26, 2026 07:42
@Vibhu-gslab Vibhu-gslab self-requested a review March 26, 2026 08:12
self.set_static_routes(
"ipv4",
self.shared_utils.mgmt_gateway,
self.inputs.mgmt_interface_vrf,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is not needed to move here as it is called only once.

@@ -112,31 +112,12 @@ def router_bgp(self) -> None:
@structured_config_contributor
def static_routes(self) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MaheshGSLAB I think we discussed that this was probably not the best to have it splitted here and then called twice and then calling a single helper that needs to discriminate between ipv4 and ipv6 routes

I am not sure there is any gain in what we are doing here for the management IP

Copy link
Copy Markdown
Contributor

@gmuloc gmuloc left a comment

Choose a reason for hiding this comment

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

Looking at this PR - this is not bringing any value towards refactoring the codebase but making it more complex.

Logic should not moved to structured_config_utils like this

lets discuss this over a call.

@github-actions github-actions bot added the state: conflict PR with conflict label Mar 26, 2026
@github-actions
Copy link
Copy Markdown

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

state: conflict PR with conflict

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants