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): structured_config for network_services router_ospf #4981

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

Conversation

Vibhu-gslab
Copy link
Contributor

Change Summary

Refactor eos_designs structured_config code for network_services router_ospf

Related Issue(s)

Fixes #

Component(s) name

arista.avd.eos_designs

Proposed changes

Refactor eos_designs structured_config code for network_services router_ospf to use classes

How to test

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)

@Vibhu-gslab Vibhu-gslab self-assigned this Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

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

@Vibhu-gslab Vibhu-gslab force-pushed the refactor_router_ospf branch 3 times, most recently from 7e76803 to 4234dda Compare February 6, 2025 12:48
@laxmikantchintakindi laxmikantchintakindi marked this pull request as ready for review February 7, 2025 11:50
@laxmikantchintakindi laxmikantchintakindi requested review from a team as code owners February 7, 2025 11:50
@github-actions github-actions bot added the state: conflict PR with conflict label Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

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

Copy link

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

@github-actions github-actions bot removed the state: conflict PR with conflict label Feb 10, 2025
@Vibhu-gslab Vibhu-gslab marked this pull request as draft February 10, 2025 05:45
@github-actions github-actions bot added the state: conflict PR with conflict label Feb 10, 2025
Copy link

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

Copy link

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

@github-actions github-actions bot removed the state: conflict PR with conflict label Feb 10, 2025
@Vibhu-gslab Vibhu-gslab marked this pull request as ready for review February 10, 2025 07:14
Copy link

process.router_id = vrf_router_id
if vrf.ospf.bfd:
process.bfd_enable = vrf.ospf.bfd
process.max_lsa = vrf.ospf.max_lsa
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be moved to the process creation.

context_keys=["id"],
)

process._update(id=process_id, passive_interface_default=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the process creation here so you can set these directly, and then call the _update_ospf_interface after.

Comment on lines +52 to +53
if vrf_router_id := self.get_vrf_router_id(vrf, tenant, vrf.ospf.router_id):
process.router_id = vrf_router_id
Copy link
Contributor

Choose a reason for hiding this comment

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

The new classes can accept a None value, so you don't need all these ifs

Comment on lines +78 to +81
if vrf.ospf.redistribute_bgp.enabled:
process.redistribute.bgp.enabled = True
if route_map := vrf.ospf.redistribute_bgp.route_map:
process.redistribute.bgp.route_map = route_map
Copy link
Contributor

Choose a reason for hiding this comment

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

This could possibly be done with a _cast_as since the keys are 1:1. If you do that, it ends up with two lines and no "if` so it would be easier done directly in the process creation so remove this function.

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.

3 participants