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 metadata #4993

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

Conversation

MaheshGSLAB
Copy link
Contributor

Change Summary

Refactor eos_designs structured_config code for metadata

Related Issue(s)

Fixes #

Component(s) name

arista.avd.<role-name>

Proposed changes

Refactor eos_designs structured_config code for metadata

How to test

Run Molecule

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 Feb 7, 2025
Copy link

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

@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 7, 2025
Comment on lines 106 to 110
self.structured_config.metadata.cv_pathfinder.applications.categories.user_defined_applications.append(
EosCliConfigGen.Metadata.CvPathfinder.Applications.Categories.UserDefinedApplicationsItem(
name=application["name"], category=category["name"]
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use append_new at lot of places here to make the code more concise

Suggested change
self.structured_config.metadata.cv_pathfinder.applications.categories.user_defined_applications.append(
EosCliConfigGen.Metadata.CvPathfinder.Applications.Categories.UserDefinedApplicationsItem(
name=application["name"], category=category["name"]
)
)
self.structured_config.metadata.cv_pathfinder.applications.categories.user_defined_applications.append_new(name=application["name"], category=category["name"]
)

Comment on lines 76 to 88
path_group = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem(name=pathgroup.name)
carriers_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.Carriers()
imported_carriers_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.ImportedCarriers()
for carrier in self.inputs.wan_carriers:
if carrier.path_group == pathgroup.name:
carrier_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.CarriersItem(name=carrier.name)
carriers_data.append(carrier_data)
if carrier.path_group in [imported_pathgroup.remote for imported_pathgroup in pathgroup.import_path_groups]:
imported_carrier_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.ImportedCarriersItem(name=carrier.name)
imported_carriers_data.append(imported_carrier_data)
path_group.carriers = carriers_data
path_group.imported_carriers = imported_carriers_data
self.structured_config.metadata.cv_pathfinder.pathgroups.append(path_group)
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
path_group = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem(name=pathgroup.name)
carriers_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.Carriers()
imported_carriers_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.ImportedCarriers()
for carrier in self.inputs.wan_carriers:
if carrier.path_group == pathgroup.name:
carrier_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.CarriersItem(name=carrier.name)
carriers_data.append(carrier_data)
if carrier.path_group in [imported_pathgroup.remote for imported_pathgroup in pathgroup.import_path_groups]:
imported_carrier_data = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem.ImportedCarriersItem(name=carrier.name)
imported_carriers_data.append(imported_carrier_data)
path_group.carriers = carriers_data
path_group.imported_carriers = imported_carriers_data
self.structured_config.metadata.cv_pathfinder.pathgroups.append(path_group)
path_group = EosCliConfigGen.Metadata.CvPathfinder.PathgroupsItem(name=pathgroup.name)
for carrier in self.inputs.wan_carriers:
if carrier.path_group == pathgroup.name:
path_group.carriers.append_new(name=carrier.name)
if carrier.path_group in [imported_pathgroup.remote for imported_pathgroup in pathgroup.import_path_groups]:
path_group.imported_carriers.append_new(name=carrier.name)
self.structured_config.metadata.cv_pathfinder.pathgroups.append(path_group)

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