-
Notifications
You must be signed in to change notification settings - Fork 220
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_cli_config_gen): Improve the aaa accounting j2 template #4636
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-4636
# Activate the virtual environment
source test-avd-pr-4636/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/MaheshGSLAB/ansible-avd.git@issue-4630#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/,issue-4630 --force
# Optional: Install AVD examples
cd test-avd-pr-4636
ansible-playbook arista.avd.install_examples |
ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg
Outdated
Show resolved
Hide resolved
ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
...lections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/aaa-accounting.yml
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/aaa_accounting.schema.yml
Outdated
Show resolved
Hide resolved
Moving to draft until comments have been addressed |
unique_keys: | ||
- commands |
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.
this help but will not cover this case (as 2 is included in the range and the unique won't be able to catch it)
command:
- commands: 2-4
- commands: 2
This is not fixable easily in the schema anyways
site3-wan1(config)#aaa accounting commands 2-4 console none
site3-wan1(config)#show run se aaa
no aaa root
aaa authorization exec default local
aaa authorization commands all default local
aaa accounting commands 2-4 console none
site3-wan1(config)#aaa accounting commands 3 console start-stop ?
group Specify server group
logging Use syslog for accounting
site3-wan1(config)#aaa accounting commands 3 console start-stop logging
site3-wan1(config)#show run se aaa
no aaa root
aaa authorization exec default local
aaa authorization commands all default local
aaa accounting commands 2,4 console none
aaa accounting commands 3 console start-stop logging
we could add something in the description to state that if using ranges then the user must make sure they don't overlap
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.
added description.
items: | ||
type: dict | ||
keys: | ||
commands: | ||
type: str | ||
convert_types: | ||
- int | ||
- int |
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.
not for this PR either but seems that you can have multiple groups in one CLI (we shall implement this if it is valid and someone needs it, until then the model is fine)
aaa accounting commands 3 console start-stop logging group radius group tacacs+
(and multiple time logging but it feels like a CLI issue)
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.
yes, we may need to update the schema.
{% if aaa_accounting.exec.default.type is arista.avd.defined %} | ||
{% set aaa_accounting_exec_default_cli = "aaa accounting exec default" %} | ||
{% if aaa_accounting.exec.default.type is arista.avd.defined('none') %} | ||
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " none" %} | ||
{% else %} | ||
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " " ~ aaa_accounting.exec.default.type %} | ||
aaa accounting exec default none | ||
{% elif aaa_accounting.exec.default.group is arista.avd.defined or aaa_accounting.exec.default.logging is arista.avd.defined(true) %} | ||
{% set exec_default_cli = "aaa accounting exec default " ~ aaa_accounting.exec.default.type %} | ||
{% if aaa_accounting.exec.default.group is arista.avd.defined %} | ||
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " group " ~ aaa_accounting.exec.default.group %} | ||
{% set exec_default_cli = exec_default_cli ~ " group " ~ aaa_accounting.exec.default.group %} | ||
{% endif %} | ||
{% if aaa_accounting.exec.default.logging is arista.avd.defined(true) %} | ||
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " logging" %} | ||
{% set exec_default_cli = exec_default_cli ~ " logging" %} | ||
{% endif %} | ||
{{ exec_default_cli }} |
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.
I feel this could be optimised by setting the value first and then checking for not none and (group or logging)
(not 100% sure for the is not
syntax inside J2 right now)
{% if aaa_accounting.exec.default.type is arista.avd.defined %} | |
{% set aaa_accounting_exec_default_cli = "aaa accounting exec default" %} | |
{% if aaa_accounting.exec.default.type is arista.avd.defined('none') %} | |
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " none" %} | |
{% else %} | |
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " " ~ aaa_accounting.exec.default.type %} | |
aaa accounting exec default none | |
{% elif aaa_accounting.exec.default.group is arista.avd.defined or aaa_accounting.exec.default.logging is arista.avd.defined(true) %} | |
{% set exec_default_cli = "aaa accounting exec default " ~ aaa_accounting.exec.default.type %} | |
{% if aaa_accounting.exec.default.group is arista.avd.defined %} | |
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " group " ~ aaa_accounting.exec.default.group %} | |
{% set exec_default_cli = exec_default_cli ~ " group " ~ aaa_accounting.exec.default.group %} | |
{% endif %} | |
{% if aaa_accounting.exec.default.logging is arista.avd.defined(true) %} | |
{% set aaa_accounting_exec_default_cli = aaa_accounting_exec_default_cli ~ " logging" %} | |
{% set exec_default_cli = exec_default_cli ~ " logging" %} | |
{% endif %} | |
{{ exec_default_cli }} | |
{% if aaa_accounting.exec.default.type is arista.avd.defined %} | |
{% set aaa_accounting_exec_default_cli = "aaa accounting exec default " ~ aaa_accounting.exec.default.type %} | |
{% if aaa_accounting.exec.default.type is not arista.avd.defined('none') and (aaa_accounting.exec.default.group is arista.avd.defined or aaa_accounting.exec.default.logging is arista.avd.defined(true)) %} | |
{% if aaa_accounting.exec.default.group is arista.avd.defined %} | |
{% set exec_default_cli = exec_default_cli ~ " group " ~ aaa_accounting.exec.default.group %} | |
{% endif %} | |
{% if aaa_accounting.exec.default.logging is arista.avd.defined(true) %} | |
{% set exec_default_cli = exec_default_cli ~ " logging" %} | |
{% endif %} | |
{{ exec_default_cli }} |
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.
if type is start-stop but did not defined any group or logging then rendering below invalid command by this logic.
aaa accounting commands 3 default start-stop
Change Summary
Improve the aaa accounting j2 template.
Related Issue(s)
Fixes #4630
Component(s) name
arista.avd.eos_cli_config_gen
Proposed changes
How to test
Run molecule with different type of inputs in aaa_accounting
Checklist
User Checklist
Repository Checklist