Skip to content

Commit

Permalink
Refactor: Make preference optional for load balance policies, using d…
Browse files Browse the repository at this point in the history
…efault 1
  • Loading branch information
gmuloc committed Jan 15, 2024
1 parent 168aff6 commit 3df2218
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;path_groups</samp>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups") | List, items: Dictionary | | | Min Length: 1 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;names</samp>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].names.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.control_plane_virtual_topology.path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |
| [<samp>&nbsp;&nbsp;policies</samp>](## "wan_virtual_topologies.policies") | List, items: Dictionary | | | | List of virtual toplogies policies.<br><br>For AutoVPN, each item in the list creates:<br> * one policy with:<br> * one `match` entry per `application_virtual_topologies` item<br> they are indexed using `10 * <list_index>` where `list_index` starts at `1`.<br> * one `default-match`<br> * one load-balance policy per `application_virtual_topologies` and one for the `default_virtual_topology`.<br> * if the policy is associated with the default VRF, a special control-plane rule is injected<br> in the policy with index `1` referring to a control-plane load-balance policy as defined under<br> `control_plane_virtual_topology`.<br><br><br>For CV Pathfinder, each item in the list creates:<br> * one policy with:<br> * one `match` entry per `application_virtual_topologies` item ordered as in the model.<br> * one last match entry for the `default` application-profile using `default_virtual_topology` information.<br> * one profile per `application_virtual_topologies` item.<br> * one profile for the `default_virtual_topology`..<br> * one load-balance policy per `application_virtual_topologies`.<br> * one load_balance policy for the `default_virtual_topology`.<br> * if the policy is associated with the default VRF, a special control-plane profile is configured<br> and injected first in the policy assigned to the `default` VRF. This profile points to a<br> control-plane load-balance policy as defined under `control_plane_virtual_topology`. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "wan_virtual_topologies.policies.[].name") | String | Required, Unique | | | Name of the AVT policy. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;application_virtual_topologies</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies") | List, items: Dictionary | | | | List of application specific virtual topologies. |
Expand All @@ -30,7 +30,7 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_groups</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups") | List, items: Dictionary | | | Min Length: 1 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;names</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].names.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.policies.[].application_virtual_topologies.[].path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_virtual_topology</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology") | Dictionary | Required | | | Default match for the policy.<br>If defined, ID is hardcoded to 1 for the AVT profile in CV Pathfinder mode.<br>If no default match should be configured, set `drop_unmatched` to `true`. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.name") | String | | | | Optional name, if not set `<policy_name>_default` is used. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drop_unmatched</samp>](## "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. |
Expand All @@ -39,7 +39,7 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_groups</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups") | List, items: Dictionary | | | Min Length: 1 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;names</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].names") | List, items: String | Required | | Min Length: 1 | List of path-group names. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].names.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].preference") | String | Required, Unique | | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preference</samp>](## "wan_virtual_topologies.policies.[].default_virtual_topology.path_groups.[].preference") | String | | `preferred` | | Valid values are 1-255 | preferred | alternate.<br><br>preferred is converted to priority 1.<br>alternate is converted to priority 2. |

=== "YAML"

Expand Down Expand Up @@ -86,7 +86,7 @@

# preferred is converted to priority 1.
# alternate is converted to priority 2.
preference: <str; required; unique>
preference: <str; default="preferred">

# List of virtual toplogies policies.

Expand Down Expand Up @@ -146,7 +146,7 @@

# preferred is converted to priority 1.
# alternate is converted to priority 2.
preference: <str; required; unique>
preference: <str; default="preferred">

# Default match for the policy.
# If defined, ID is hardcoded to 1 for the AVT profile in CV Pathfinder mode.
Expand Down Expand Up @@ -174,5 +174,5 @@

# preferred is converted to priority 1.
# alternate is converted to priority 2.
preference: <str; required; unique>
preference: <str; default="preferred">
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

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 @@ -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
Expand All @@ -41,3 +40,4 @@ $defs:
preferred is converted to priority 1.
alternate is converted to priority 2.
default: "preferred"

0 comments on commit 3df2218

Please sign in to comment.