From 4ce6c346d0b637780de7b4eaeaa6c1b84d54b098 Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 13 Nov 2023 13:38:19 +0100 Subject: [PATCH] Refactor: Address PR comments --- .../documentation/devices/router-path-selection.md | 2 +- .../intended/configs/router-path-selection.cfg | 2 +- .../docs/tables/router-path-selection.md | 11 ++++++----- .../schemas/eos_cli_config_gen.jsonschema.json | 5 ++--- .../schemas/eos_cli_config_gen.schema.yml | 8 +++++--- .../schema_fragments/router_path_selection.schema.yml | 7 ++++--- .../templates/eos/router-path-selection.j2 | 10 ++++------ 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-path-selection.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-path-selection.md index a1f23268780..baea42bb6bc 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-path-selection.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-path-selection.md @@ -213,7 +213,7 @@ router path-selection jitter 666 latency 42 loss-rate 42.42 - path-group PG-1 + path-group PG-1 priority 1 path-group PG-3 ! policy DPS-P-1 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-path-selection.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-path-selection.cfg index e79215f81c1..f5bced375c8 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-path-selection.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-path-selection.cfg @@ -66,7 +66,7 @@ router path-selection jitter 666 latency 42 loss-rate 42.42 - path-group PG-1 + path-group PG-1 priority 1 path-group PG-3 ! policy DPS-P-1 diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-path-selection.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-path-selection.md index e11e2d5da3d..1e69cb1c1b5 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-path-selection.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-path-selection.md @@ -40,10 +40,10 @@ | [      hop_count_lower](## "router_path_selection.load_balance_policies.[].hop_count_lower") | Boolean | | | | Prefer paths with lowest hop-count. | | [      jitter](## "router_path_selection.load_balance_policies.[].jitter") | Integer | | | Min: 0
Max: 10000 | Jitter requirement for this load balance policy in milliseconds. | | [      latency](## "router_path_selection.load_balance_policies.[].latency") | Integer | | | Min: 0
Max: 10000 | One way delay requirement for this load balance policy in milliseconds. | - | [      loss_rate](## "router_path_selection.load_balance_policies.[].loss_rate") | String | | | Pattern: ^\d+(\.\d{1,2})?$ | Loss Rate requirement for this load balance policy in milliseconds. | + | [      loss_rate](## "router_path_selection.load_balance_policies.[].loss_rate") | String | | | Pattern: ^\d+(\.\d{1,2})?$ | Loss Rate requirement in percentage for this load balance policy.
Value between 0.00 and 100.00 % | | [      path_groups](## "router_path_selection.load_balance_policies.[].path_groups") | List, items: Dictionary | | | | List of path-groups to use for this load balance policy. | | [        - name](## "router_path_selection.load_balance_policies.[].path_groups.[].name") | String | Required, Unique | | | Path-group name | - | [          priority](## "router_path_selection.load_balance_policies.[].path_groups.[].priority") | Integer | | `1` | Min: 1
Max: 65535 | Priority for this path-group.
Default is 1 and not rendred in EOS cli. | + | [          priority](## "router_path_selection.load_balance_policies.[].path_groups.[].priority") | Integer | | | Min: 1
Max: 65535 | Priority for this path-group.
The EOS default value is 1. | | [  policies](## "router_path_selection.policies") | List, items: Dictionary | | | | | | [    - name](## "router_path_selection.policies.[].name") | String | Required, Unique | | | DPS policy name. | | [      default_match](## "router_path_selection.policies.[].default_match") | Dictionary | | | | | @@ -136,7 +136,8 @@ # One way delay requirement for this load balance policy in milliseconds. latency: - # Loss Rate requirement for this load balance policy in milliseconds. + # Loss Rate requirement in percentage for this load balance policy. + # Value between 0.00 and 100.00 % loss_rate: # List of path-groups to use for this load balance policy. @@ -146,8 +147,8 @@ - name: # Priority for this path-group. - # Default is 1 and not rendred in EOS cli. - priority: + # The EOS default value is 1. + priority: policies: # DPS policy name. diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.jsonschema.json b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.jsonschema.json index d3174a88a96..ece1a65f7fa 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.jsonschema.json +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.jsonschema.json @@ -20662,7 +20662,7 @@ }, "loss_rate": { "type": "string", - "description": "Loss Rate requirement for this load balance policy in milliseconds.", + "description": "Loss Rate requirement in percentage for this load balance policy.\nValue between 0.00 and 100.00 %", "pattern": "^\\d+(\\.\\d{1,2})?$", "title": "Loss Rate" }, @@ -20679,10 +20679,9 @@ }, "priority": { "type": "integer", - "description": "Priority for this path-group.\nDefault is 1 and not rendred in EOS cli.", + "description": "Priority for this path-group.\nThe EOS default value is 1.", "minimum": 1, "maximum": 65535, - "default": 1, "title": "Priority" } }, diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.schema.yml b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.schema.yml index 4be03541ae0..fa091cf19e0 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/eos_cli_config_gen.schema.yml @@ -11844,7 +11844,10 @@ keys: max: 10000 loss_rate: type: str - description: Loss Rate requirement for this load balance policy in milliseconds. + description: 'Loss Rate requirement in percentage for this load balance + policy. + + Value between 0.00 and 100.00 %' convert_types: - int - float @@ -11863,12 +11866,11 @@ keys: type: int description: 'Priority for this path-group. - Default is 1 and not rendred in EOS cli.' + The EOS default value is 1.' convert_types: - str min: 1 max: 65535 - default: 1 policies: type: list primary_key: name diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_path_selection.schema.yml b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_path_selection.schema.yml index 69caefa677b..76d58c94c03 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_path_selection.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_path_selection.schema.yml @@ -143,7 +143,9 @@ keys: max: 10000 loss_rate: type: str - description: Loss Rate requirement for this load balance policy in milliseconds. + description: |- + Loss Rate requirement in percentage for this load balance policy. + Value between 0.00 and 100.00 % convert_types: - int - float @@ -162,12 +164,11 @@ keys: type: int description: |- Priority for this path-group. - Default is 1 and not rendred in EOS cli. + The EOS default value is 1. convert_types: - str min: 1 max: 65535 - default: 1 policies: type: list primary_key: name diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-path-selection.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-path-selection.j2 index 793acbee4dc..df74c511f45 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-path-selection.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-path-selection.j2 @@ -92,15 +92,13 @@ router path-selection {% endif %} {# TODO remove inplace update once Ansible 2.13 is dropped and use groupby default instead #} {% for path_group in load_balance_policy.path_groups | arista.avd.default([]) %} -{% if path_group.priority is not arista.avd.defined %} -{% do path_group.update({"priority": 1}) %} -{% endif %} +{% do path_group.update({"_priority": path_group.priority | arista.avd.default(1)}) %} {% endfor %} -{% for priority, entries in load_balance_policy.path_groups | groupby("priority") %} +{% for priority, entries in load_balance_policy.path_groups | groupby("_priority") %} {% for entry in entries | arista.avd.natural_sort("name") %} {% set path_group_cli = "path-group " ~ entry.name %} -{% if priority != 1 %} -{% set path_group_cli = path_group_cli ~ " priority " ~ priority %} +{% if entry.priority is arista.avd.defined %} +{% set path_group_cli = path_group_cli ~ " priority " ~ entry.priority %} {% endif %} {{ path_group_cli }} {% endfor %}