-
Notifications
You must be signed in to change notification settings - Fork 235
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
base: devel
Are you sure you want to change the base?
Conversation
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 |
self.structured_config.metadata.cv_pathfinder.applications.categories.user_defined_applications.append( | ||
EosCliConfigGen.Metadata.CvPathfinder.Applications.Categories.UserDefinedApplicationsItem( | ||
name=application["name"], category=category["name"] | ||
) | ||
) |
There was a problem hiding this comment.
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
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"] | |
) |
for more information, see https://pre-commit.ci
a484ce1
to
3fdcb0e
Compare
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
|
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
Repository Checklist