From 3df22188f41ef26bdd887b1ce5f7d93e99eb3a3a Mon Sep 17 00:00:00 2001 From: gmuloc Date: Mon, 15 Jan 2024 12:33:03 +0100 Subject: [PATCH] Refactor: Make preference optional for load balance policies, using default 1 --- .../inventory/group_vars/CV_PATHFINDER_TESTS.yml | 2 +- .../docs/tables/wan-virtual-topologies.md | 12 ++++++------ .../python_modules/network_services/utils.py | 2 +- .../eos_designs/schemas/eos_designs.jsonschema.json | 12 ++++++------ .../roles/eos_designs/schemas/eos_designs.schema.yml | 2 +- .../defs_virtual_topology.schema.yml | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/CV_PATHFINDER_TESTS.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/CV_PATHFINDER_TESTS.yml index 0284d4db182..b231913b8bb 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/CV_PATHFINDER_TESTS.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/CV_PATHFINDER_TESTS.yml @@ -219,8 +219,8 @@ wan_virtual_topologies: - name: DEFAULT-AVT-POLICY default_virtual_topology: path_groups: + # No prefence to check the default. - names: [INET, Equinix] - preference: preferred - names: [MPLS] preference: 42 application_virtual_topologies: diff --git a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/wan-virtual-topologies.md b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/wan-virtual-topologies.md index e026124cbdd..3c38320dced 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/wan-virtual-topologies.md +++ b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/wan-virtual-topologies.md @@ -18,7 +18,7 @@ | [    path_groups](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups") | List, items: Dictionary | | | Min Length: 1 | | | [      - names](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. | | [          - <str>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].names.[]") | String | | | | | - | [        preference](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | + | [        preference](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | | [  policies](## "wan_virtual_topologies.policies") | List, items: Dictionary | | | | List of virtual toplogies policies.

For AutoVPN, each item in the list creates:
* one policy with:
* one `match` entry per `application_virtual_topologies` item
they are indexed using `10 * ` where `list_index` starts at `1`.
* one `default-match`
* one load-balance policy per `application_virtual_topologies` and one for the `default_virtual_topology`.
* if the policy is associated with the default VRF, a special control-plane rule is injected
in the policy with index `1` referring to a control-plane load-balance policy as defined under
`control_plane_virtual_topology`.


For CV Pathfinder, each item in the list creates:
* one policy with:
* one `match` entry per `application_virtual_topologies` item ordered as in the model.
* one last match entry for the `default` application-profile using `default_virtual_topology` information.
* one profile per `application_virtual_topologies` item.
* one profile for the `default_virtual_topology`..
* one load-balance policy per `application_virtual_topologies`.
* one load_balance policy for the `default_virtual_topology`.
* if the policy is associated with the default VRF, a special control-plane profile is configured
and injected first in the policy assigned to the `default` VRF. This profile points to a
control-plane load-balance policy as defined under `control_plane_virtual_topology`. | | [    - name](## "wan_virtual_topologies.policies.[].name") | String | Required, Unique | | | Name of the AVT policy. | | [      application_virtual_topologies](## "wan_virtual_topologies.policies.[].application_virtual_topologies") | List, items: Dictionary | | | | List of application specific virtual topologies. | @@ -30,7 +30,7 @@ | [          path_groups](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups") | List, items: Dictionary | | | Min Length: 1 | | | [            - names](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. | | [                - <str>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].names.[]") | String | | | | | - | [              preference](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | + | [              preference](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | | [      default_virtual_topology](## "wan_virtual_topologies.policies.[].default_virtual_topology") | Dictionary | Required | | | Default match for the policy.
If defined, ID is hardcoded to 1 for the AVT profile in CV Pathfinder mode.
If no default match should be configured, set `drop_unmatched` to `true`. | | [        name](## "wan_virtual_topologies.policies.[].default_virtual_topology.name") | String | | | | Optional name, if not set `_default` is used. | | [        drop_unmatched](## "wan_virtual_topologies.policies.[].default_virtual_topology.drop_unmatched") | Boolean | | `False` | | When set, no `catch-all` match is configured for the policy and unmatched traffic is dropped. | @@ -39,7 +39,7 @@ | [        path_groups](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups") | List, items: Dictionary | | | Min Length: 1 | | | [          - names](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. | | [              - <str>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].names.[]") | String | | | | | - | [            preference](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | + | [            preference](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.

preferred is converted to priority 1.
alternate is converted to priority 2. | === "YAML" @@ -86,7 +86,7 @@ # preferred is converted to priority 1. # alternate is converted to priority 2. - preference: + preference: # List of virtual toplogies policies. @@ -146,7 +146,7 @@ # preferred is converted to priority 1. # alternate is converted to priority 2. - preference: + preference: # Default match for the policy. # If defined, ID is hardcoded to 1 for the AVT profile in CV Pathfinder mode. @@ -174,5 +174,5 @@ # preferred is converted to priority 1. # alternate is converted to priority 2. - preference: + preference: ``` diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/utils.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/utils.py index d759c815da8..a3b8333a810 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/utils.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/utils.py @@ -261,7 +261,7 @@ def _generate_wan_load_balance_policy(self, name: str, input_dict: dict, default # TODO check if it cannot be optimized further in shared_utils or validated in a global fashion - maybe # schema? # check that the LB policy has at least one prio 1 / preferred EVEN if the path group is not configured. - if (priority := self._path_group_preference_to_eos_priority(get(policy_entry, "preference", required=True))) == 1: + if (priority := self._path_group_preference_to_eos_priority(get(policy_entry, "preference", default=1))) == 1: at_least_one_priority_1_found = True for path_group_name in policy_entry.get("names"): # Skip path-group on this device if not present on the router except for pathfinders diff --git a/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.jsonschema.json b/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.jsonschema.json index acc5019c2a7..570142bc4ea 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.jsonschema.json +++ b/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.jsonschema.json @@ -24020,12 +24020,12 @@ "preference": { "type": "string", "description": "Valid values are 1-255 | preferred | alternate.\n\npreferred is converted to priority 1.\nalternate is converted to priority 2.", + "default": "preferred", "title": "Preference" } }, "required": [ - "names", - "preference" + "names" ], "additionalProperties": false, "patternProperties": { @@ -24107,12 +24107,12 @@ "preference": { "type": "string", "description": "Valid values are 1-255 | preferred | alternate.\n\npreferred is converted to priority 1.\nalternate is converted to priority 2.", + "default": "preferred", "title": "Preference" } }, "required": [ - "names", - "preference" + "names" ], "additionalProperties": false, "patternProperties": { @@ -24180,12 +24180,12 @@ "preference": { "type": "string", "description": "Valid values are 1-255 | preferred | alternate.\n\npreferred is converted to priority 1.\nalternate is converted to priority 2.", + "default": "preferred", "title": "Preference" } }, "required": [ - "names", - "preference" + "names" ], "additionalProperties": false, "patternProperties": { diff --git a/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.schema.yml b/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.schema.yml index 0699b5d47d6..4ee291cb48e 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_designs/schemas/eos_designs.schema.yml @@ -7976,7 +7976,6 @@ $defs: $ref: eos_cli_config_gen#keys/router_adaptive_virtual_topology/keys/policies/items/keys/matches/items/keys/dscp path_groups: type: list - primary_key: preference min_length: 1 items: type: dict @@ -7998,3 +7997,4 @@ $defs: preferred is converted to priority 1. alternate is converted to priority 2.' + default: preferred diff --git a/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_virtual_topology.schema.yml b/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_virtual_topology.schema.yml index 298a177be2c..d56988ce848 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_virtual_topology.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_virtual_topology.schema.yml @@ -20,7 +20,6 @@ $defs: $ref: "eos_cli_config_gen#keys/router_adaptive_virtual_topology/keys/policies/items/keys/matches/items/keys/dscp" path_groups: type: list - primary_key: preference min_length: 1 items: type: dict @@ -41,3 +40,4 @@ $defs: preferred is converted to priority 1. alternate is converted to priority 2. + default: "preferred"