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 @@ -31,17 +31,14 @@ aaa_accounting:
type: start-stop
logging: false
group: TACACS1
# It should not include logging into command
# As type is none hence logging will not render in config as per actual EOS
- commands: 2
type: none
logging: true
# It should not generate the command
# 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
# It should not generate the command
- commands: 4
logging: false
default:
- commands: all
type: start-stop
Expand All @@ -55,11 +52,11 @@ aaa_accounting:
type: start-stop
logging: false
group: TACACS
# It should not include logging into command
# As type is none hence logging will not render in config as per actual EOS
- commands: 2
type: none
logging: true
# It should not generate the command
# 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 @@ -5,51 +5,45 @@
#}
{# eos - aaa accounting #}
{% if aaa_accounting is arista.avd.defined %}
{% if aaa_accounting.exec.console.type is arista.avd.defined %}
{% if aaa_accounting.exec.console.type is arista.avd.defined('none') %}
{% if aaa_accounting.exec.console.type is arista.avd.defined('none') %}
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 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 exec_console_cli = exec_console_cli ~ " logging" %}
{% endif %}
{{ exec_console_cli }}
{% 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 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 exec_console_cli = exec_console_cli ~ " logging" %}
{% endif %}
{{ 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 %}
{% if command_default.type is arista.avd.defined('none') %}
{% 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 }}
{% 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 %}
{% endfor %}
{% endif %}
{% if aaa_accounting.exec.default.type is arista.avd.defined %}
{% if aaa_accounting.exec.default.type is arista.avd.defined('none') %}
{% if aaa_accounting.exec.default.type is arista.avd.defined('none') %}
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 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 }}
{% 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 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 }}
{% 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 @@ -59,19 +53,17 @@ aaa accounting dot1x default {{ aaa_accounting.dot1x.default.type }} group {{ aa
{% endif %}
{% 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 %}
{% if command_default.type is arista.avd.defined('none') %}
{% 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 }}
{% 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 %}
{% endfor %}
{% endif %}
Expand Down

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 @@ -18,6 +18,7 @@ keys:
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
required: true
group:
description: Group Name.
type: str
Expand All @@ -29,6 +30,7 @@ keys:
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
required: true
group:
description: Group Name.
type: str
Expand All @@ -43,6 +45,7 @@ keys:
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
required: true
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
group:
description: Group Name.
type: str
Expand All @@ -55,6 +58,7 @@ keys:
type:
type: str
valid_values: ["start-stop", "stop-only"]
required: true
group:
description: Group Name.
type: str
Expand All @@ -63,35 +67,41 @@ keys:
keys:
console:
type: list
unique_keys:
- commands
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
items:
type: dict
keys:
commands:
type: str
convert_types:
- int
- int
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
description: Privilege level 'all' or 0-15.
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
required: true
group:
description: Group Name.
type: str
logging:
type: bool
default:
type: list
unique_keys:
- commands
items:
type: dict
keys:
commands:
type: str
convert_types:
- int
- int
description: Privilege level 'all' or 0-15.
type:
type: str
valid_values: ["none", "start-stop", "stop-only"]
required: true
group:
description: Group Name.
type: str
Expand Down
Loading