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_cli_config_gen): Improve the aaa accounting j2 template #4636

Merged
merged 12 commits into from
Dec 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1207,12 +1207,16 @@ aaa authorization commands 10,15 default group tacacs+ local
| Commands - Console | all | start-stop | TACACS | True |
| Commands - Console | 0 | start-stop | - | True |
| Commands - Console | 1 | start-stop | TACACS1 | False |
| Commands - Console | 2 | none | - | True |
| Commands - Console | 3 | start-stop | - | False |
| Exec - Default | - | start-stop | TACACS | True |
| System - Default | - | start-stop | TACACS | - |
| Dot1x - Default | - | start-stop | RADIUS | - |
| Commands - Default | all | start-stop | TACACS | True |
| Commands - Default | 0 | start-stop | - | True |
| Commands - Default | 1 | start-stop | TACACS | False |
| Commands - Default | 2 | none | - | True |
| Commands - Default | 3 | start-stop | - | False |

#### AAA Accounting Device Configuration

Expand All @@ -1221,12 +1225,14 @@ aaa accounting exec console start-stop group TACACS logging
aaa accounting commands all console start-stop group TACACS logging
aaa accounting commands 0 console start-stop logging
aaa accounting commands 1 console start-stop group TACACS1
aaa accounting commands 2 console none
aaa accounting exec default start-stop group TACACS logging
aaa accounting system default start-stop group TACACS
aaa accounting dot1x default start-stop group RADIUS
aaa accounting commands all default start-stop group TACACS logging
aaa accounting commands 0 default start-stop logging
aaa accounting commands 1 default start-stop group TACACS
aaa accounting commands 2 default none
```

## Management Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,14 @@ aaa accounting exec console start-stop group TACACS logging
aaa accounting commands all console start-stop group TACACS logging
aaa accounting commands 0 console start-stop logging
aaa accounting commands 1 console start-stop group TACACS1
aaa accounting commands 2 console none
aaa accounting exec default start-stop group TACACS logging
aaa accounting system default start-stop group TACACS
aaa accounting dot1x default start-stop group RADIUS
aaa accounting commands all default start-stop group TACACS logging
aaa accounting commands 0 default start-stop logging
aaa accounting commands 1 default start-stop group TACACS
aaa accounting commands 2 default none
!
cvx
no shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ aaa_accounting:
type: start-stop
logging: false
group: TACACS1
# As type is none hence logging will not render in config as per actual EOS
- commands: 2
type: none
logging: true
# If type is start-stop or stop-only then logging should be true or group should be defined to render the config
- commands: 3
type: start-stop
logging: false
default:
- commands: all
type: start-stop
Expand All @@ -44,3 +52,11 @@ aaa_accounting:
type: start-stop
logging: false
group: TACACS
# As type is none hence logging will not render in config as per actual EOS
- commands: 2
type: none
logging: true
# If type is start-stop or stop-only then logging should be true or group should be defined to render the config
- commands: 3
type: start-stop
logging: false

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,50 @@
{# eos - aaa accounting #}
{% if aaa_accounting is arista.avd.defined %}
{% if aaa_accounting.exec.console.type is arista.avd.defined %}
MaheshGSLAB marked this conversation as resolved.
Show resolved Hide resolved
{% set aaa_accounting_exec_console_cli = "aaa accounting exec console" %}
{% if aaa_accounting.exec.console.type is arista.avd.defined('none') %}
{% set aaa_accounting_exec_console_cli = aaa_accounting_exec_console_cli ~ " none" %}
{% else %}
{% set aaa_accounting_exec_console_cli = aaa_accounting_exec_console_cli ~ " " ~ aaa_accounting.exec.console.type %}
aaa accounting exec console none
{% elif aaa_accounting.exec.console.group is arista.avd.defined or aaa_accounting.exec.console.logging is arista.avd.defined(true) %}
{% set exec_console_cli = "aaa accounting exec console " ~ aaa_accounting.exec.console.type %}
{% if aaa_accounting.exec.console.group is arista.avd.defined %}
{% set aaa_accounting_exec_console_cli = aaa_accounting_exec_console_cli ~ " group " ~ aaa_accounting.exec.console.group %}
{% set exec_console_cli = exec_console_cli ~ " group " ~ aaa_accounting.exec.console.group %}
{% endif %}
{% if aaa_accounting.exec.console.logging is arista.avd.defined(true) %}
{% set aaa_accounting_exec_console_cli = aaa_accounting_exec_console_cli ~ " logging" %}
{% set exec_console_cli = exec_console_cli ~ " logging" %}
{% endif %}
{{ exec_console_cli }}
{% endif %}
{{ aaa_accounting_exec_console_cli }}
{% endif %}
{% if aaa_accounting.commands.console is arista.avd.defined %}
{% for command_default in aaa_accounting.commands.console %}
{% if command_default.commands is arista.avd.defined and command_default.type is arista.avd.defined %}
{% set aaa_accounting_commands_commands_console_cli = "aaa accounting commands " ~ command_default.commands ~ " console " ~ command_default.type %}
{% if command_default.group is arista.avd.defined %}
{% set aaa_accounting_commands_commands_console_cli = aaa_accounting_commands_commands_console_cli ~ " group " ~ command_default.group %}
{% endif %}
{% if command_default.logging is arista.avd.defined(true) %}
{% set aaa_accounting_commands_commands_console_cli = aaa_accounting_commands_commands_console_cli ~ " logging" %}
{% if command_default.type is arista.avd.defined('none') %}
aaa accounting commands {{ command_default.commands }} console none
{% elif command_default.group is arista.avd.defined or command_default.logging is arista.avd.defined(true) %}
{% set commands_console_cli = "aaa accounting commands " ~ command_default.commands ~ " console " ~ command_default.type %}
{% if command_default.group is arista.avd.defined %}
{% set commands_console_cli = commands_console_cli ~ " group " ~ command_default.group %}
{% endif %}
{% if command_default.logging is arista.avd.defined(true) %}
{% set commands_console_cli = commands_console_cli ~ " logging" %}
{% endif %}
{{ commands_console_cli }}
{% endif %}
{% endif %}
{{ aaa_accounting_commands_commands_console_cli }}
{% endfor %}
{% endif %}
{% 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 }}
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
{{ aaa_accounting_exec_default_cli }}
{% endif %}
{% if aaa_accounting.system.default.type is arista.avd.defined and aaa_accounting.system.default.group is arista.avd.defined %}
aaa accounting system default {{ aaa_accounting.system.default.type }} group {{ aaa_accounting.system.default.group }}
Expand All @@ -58,15 +60,19 @@ aaa accounting dot1x default {{ aaa_accounting.dot1x.default.type }} group {{ aa
{% if aaa_accounting.commands.default is arista.avd.defined %}
{% for command_default in aaa_accounting.commands.default %}
{% if command_default.commands is arista.avd.defined and command_default.type is arista.avd.defined %}
{% set aaa_accounting_commands_commands_default_cli = "aaa accounting commands " ~ command_default.commands ~ " default " ~ command_default.type %}
{% if command_default.group is arista.avd.defined %}
{% set aaa_accounting_commands_commands_default_cli = aaa_accounting_commands_commands_default_cli ~ " group " ~ command_default.group %}
{% endif %}
{% if command_default.logging is arista.avd.defined(true) %}
{% set aaa_accounting_commands_commands_default_cli = aaa_accounting_commands_commands_default_cli ~ " logging" %}
{% if command_default.type is arista.avd.defined('none') %}
aaa accounting commands {{ command_default.commands }} default none
{% elif command_default.group is arista.avd.defined or command_default.logging is arista.avd.defined(true) %}
{% set commands_default_cli = "aaa accounting commands " ~ command_default.commands ~ " default " ~ command_default.type %}
{% if command_default.group is arista.avd.defined %}
{% set commands_default_cli = commands_default_cli ~ " group " ~ command_default.group %}
{% endif %}
{% if command_default.logging is arista.avd.defined(true) %}
{% set commands_default_cli = commands_default_cli ~ " logging" %}
{% endif %}
{{ commands_default_cli }}
{% endif %}
{% endif %}
{{ aaa_accounting_commands_commands_default_cli }}
{% endfor %}
{% endif %}
{% endif %}
8 changes: 4 additions & 4 deletions python-avd/pyavd/_eos_cli_config_gen/schema/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ keys:
commands:
type: str
convert_types:
- int
description: Privilege level 'all' or 0-15.
- int
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
description: Privilege level 'all' or 0-15. Ensure that if ranges are used, they do not overlap with one another.
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
Expand All @@ -87,8 +87,8 @@ keys:
commands:
type: str
convert_types:
- int
description: Privilege level 'all' or 0-15.
- int
description: Privilege level 'all' or 0-15. Ensure that if ranges are used, they do not overlap with one another.
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
Expand Down