This document outlines the steps and checklist for contributing to the eos_cli_config_gen
role under Arista AVD.
- Prepare development environment.
- Create the schema.
- Develop Jinja2 templates (eos and documentation).
- Run pre-commit to build schema and templates
- Validate With Molecule Tests
- Update documentation as needed.
- Run pre-commit checks to ensure compliance.
- Review all changes before submission.
- Raise a PR to the Arista AVD GitHub repository
Follow the Development Tooling Guide.
Add the schema for new feature as per EOS CLI to the appropriate schema fragments file in the python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments
directory or create a new schema file if adding a top-level feature.
Please refer to the schema documentation for details on the various keys in the schema: Schema Documentation.
- Primary Key Placement: For list-type data-models, place primary keys at the top, for readability.
- Key Naming:
- Follow EOS CLI for key names, when creating new schema keys.
- Use plural for keys that represent multiple elements (e.g., sample_policies).
- Descriptions:
- Only add descriptions to the keys when they provide additional context beyond the key name.
- Refer Arista documentation for description content.
- Ensure all descriptions end with punctuation.
- Highlight the key names in description, like -
<key_name>
.
- Type Conversion:
- Add
convert_types: [str]
fortype: int
keys. - Add
convert_types: [int]
fortype: str
if it can be numeric.
- Add
- Defaults: Avoid using
default
in eos_cli_config_gen. - Min/Max: Specify min/max values in the schema if they are defined in the EOS CLI. Make sure to check on different hardware platforms.
- Valid_Values: Specify valid options in the schema as per the EOS CLI and ensure compatibility across different hardware platforms.
- Required: Set
required: true
if the key must be provided to produce a valid configuration.
Edit the appropriate Jinja2 templates in python-avd/pyavd/_eos_cli_config_gen/j2templates/eos
and python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation
to generate the desired configuration and documentation.
When adding a top-level feature, add a new Jinja2 template following the naming convention and modify the python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-intended-config.j2
and python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-device-documentation.j2
to add these new templates where relevant, in particular to respect EOS CLI order.
- Code Indentation: Keep less indented code to improve readability.
- Variable Naming: Use meaningful variable names. Avoid short variables like
ei
forethernet_interface
- Use AVD filters: Use AVD filters for code optimization - AVD Filters.
- Natural Sorting: Use
arista.avd.natural_sort
for sorting thefor loops
after checking on EOS CLI. - Defined Checks:
- Avoid
arista.avd.defined
check for parent keys when directly checking for child keys. - Avoid
arista.avd.defined
check for primary and required keys. - Avoid
arista.avd.defined
check when usingarista.avd.default()
andarista.avd.natural_sort
filters.
- Avoid
- Password Security: Avoid displaying passwords in the documentation template and use the
arista.avd.hide_passwords
filter to hide it. - Config Order: Ensure the order and indentation of configuration matches EOS CLI.
- Exclamation Marks: Place exclamation marks
!
correctly as per the EOS running-config. - Along with EOS config template, update the documentation template as well (if required).
- Implement only commands visible in
show running-config all
of the EOS device. We should not hide config if given by the user. - Validate the template using j2lint tool, run
pre-commit run j2lint --all
.
Run pre-commit run --all
, this will trigger recompiling the schemas and the templates you have created.
!!! Note
When using Ansible (either through molecule or from a test repo), AVD is able to detect when it is running from source, and recompiles schemas and templates automatically during the "Verify Requirements" step, as outlined in the [Development Tooling Guide](https://avd.arista.com/stable/docs/contribution/development-tooling.html).
However, if you are using pyavd or need to manually recompile the schemas and templates for any other reason, you can run the following commands:
`pre-commit run schemas --all` to regenerate the eos_cli_config_gen schema.
`pre-commit run templates --all` to regenerate the templates.
These commands should be executed whenever the schema or templates are modified, even if only a description is updated.
- Add some molecule tests in the
ansible_collections/arista/avd/molecule/eos_cli_config_gen
scenario or other relevant molecule scenario exercising the new knob configuration. - Update the
host_vars
files:- Modify or add the
molecule/<scenario_name>/host_vars/hostX/<key_name>.yml
file to include the new configuration knobs. - If multiple files are required to cover all the test cases:
- Add the additional test cases to the next host directory, e.g.,
host_vars/host2/<key_name>.yml
,host_vars/host3/<key_name>.yml
, etc. - Ensure each file represents unique scenarios or configurations to validate different combinations.
- Add the additional test cases to the next host directory, e.g.,
- Ensure that the new keys are thoroughly tested with various valid values and edge cases.
- Modify or add the
- When marking any key as "deprecated", move the related tests to the
eos_cli_config_gen_deprecated_vars
molecule scenario and add any missing tests if necessary. - Run
molecule converge -s <scenario_name>
from the pathansible_collections/arista/avd/
to execute the molecule tests locally and generate the new expected configuration and documentation for newly added test-cases. - To execute all the molecule scenarios, run
make refresh-facts
from the pathansible_collections/arista/avd/molecule
and verify the tests. - Check the PyAVD test coverage report by running
tox -e coverage,report
and work on improving the coverage where possible. - Test the generated configuration using eAPI or CloudVision in a relevant lab, if available, to ensure it works as intended.
!!! Note
Running `make refesh-facts` can be long and it can be preferable to rerun only the required scenarios using `molecule converge -s <scenario_name>` multiple times.
If the proposed feature requires any changes to the documentation, make sure to update it accordingly.
Run all pre-commit checks pre-commit run --all
to ensure that all files added or modified are correctly following the coding standards and formatting rules. Running these checks also ensures that the changes pass CI checks.
!!! Note
Breaking changes should be documented in the release notes / porting guide. Please advise a maintainer on the PR.
- Before pushing the changes to GitHub, carefully review all the modifications.
- Confirm that all new features work as intended and that existing features are unaffected.
- Once satisfied, proceed to push the changes to the repository.
- After completing the self-review, raise a pull request (PR) to the Arista AVD GitHub repository for further review and integration.
- Use draft PRs when the changes are not ready for review.
- Tag maintainers with questions, even after pushing changes, for clarity and guidance, or discuss in the related issue if needed.
- Check that all the CI checks are passing.
- If the PR addresses an issue raised in the repository, confirm that the issue is fully resolved by the PR.
- Refer to the Arista EOS documentation for a deeper understanding of the proposed feature.
- Tag maintainers with questions or concerns regarding the proposed changes.
- Verify that the schema adheres to EOS CLI and all relevant guidelines mentioned above.
- Ensure that the min/max and valid-values are specified in the schema if they are defined in the EOS CLI.
- Ensure that Jinja2 templates follow all the guidelines mentioned above.
- Check that the template generates valid configuration and documentation, maintaining the same configuration order and indentation as EOS CLI.
- Check out the PR in a local IDE using the instructions in the PR comment and run all tests to ensure functionality.
- Test the generated configuration via eAPI or CloudVision in a relevant lab, if available. Otherwise, mention in your review comment that lab verification was not possible.
- Add inline suggestions whenever possible, and if providing code suggestions, test them locally to ensure they work as intended.
- Check that the molecule tests are added for the new feature.
- If any keys are marked as deprecated, ensure that the associated tests are moved to the
eos_cli_config_gen_deprecated_vars
scenario. - If the proposed feature requires any changes to the documentation, ensure that it is updated accordingly.
- Approve the PR if everything looks good.