Skip to content

Commit

Permalink
Feat(eos_cli_config_gen): Adding options for path-selection lb polici…
Browse files Browse the repository at this point in the history
…es (#3334)

Co-authored-by: Carl Buchmann <[email protected]>
  • Loading branch information
gmuloc and carlbuchmann authored Nov 16, 2023
1 parent eb873a1 commit 3557bbe
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ interface Management1

#### Load-balance policies

| Policy name | Path group(s) |
| ----------- | ------------- |
| LB-P-1 | PG-2<br>PG-3 |
| LB-P-2 | PG-1 |
| Policy Name | Jitter (ms) | Latency (ms) | Loss Rate (%) | Path Groups (priority) | Lowest Hop Count |
| ----------- | ----------- | ------------ | ------------- | ---------------------- | ---------------- |
| LB-P-1 | - | - | 17 | PG-5 (1)<br>PG-2 (42)<br>PG-4 (42)<br>PG-3 (666) | True |
| LB-P-2 | 666 | 42 | 42.42 | PG-1 (1)<br>PG-3 (1) | False |

#### DPS policies

Expand Down Expand Up @@ -202,11 +202,19 @@ router path-selection
path-group PG-4
!
load-balance policy LB-P-1
path-group PG-3
path-group PG-2
hop count lowest
loss-rate 17
path-group PG-5
path-group PG-2 priority 42
path-group PG-4 priority 42
path-group PG-3 priority 666
!
load-balance policy LB-P-2
path-group PG-1
jitter 666
latency 42
loss-rate 42.42
path-group PG-1 priority 1
path-group PG-3
!
policy DPS-P-1
default-match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ router path-selection
path-group PG-4
!
load-balance policy LB-P-1
path-group PG-3
path-group PG-2
hop count lowest
loss-rate 17
path-group PG-5
path-group PG-2 priority 42
path-group PG-4 priority 42
path-group PG-3 priority 666
!
load-balance policy LB-P-2
path-group PG-1
jitter 666
latency 42
loss-rate 42.42
path-group PG-1 priority 1
path-group PG-3
!
policy DPS-P-1
default-match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,27 @@ router_path_selection:
load_balance_policies:
# Out of order to test sorting
- name: LB-P-2
latency: 42
jitter: 666
loss_rate: "42.42"
path_groups:
- PG-1
# checking priority 1 comes first
- name: PG-3
- name: PG-1
priority: 1
- name: LB-P-1
lowest_hop_count: true
loss_rate: 17
path_groups:
- PG-3
- PG-2
# checking priority 1 comes first
- name: PG-5
- name: PG-3
priority: 666
# Checking ordering for same priority
- name: PG-4
priority: 42
- name: PG-2
priority: 42
policies:
# Out of order to test sorting
- name: DPS-P-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "router_path_selection.path_groups.[].static_peers.[].ipv4_addresses.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;load_balance_policies</samp>](## "router_path_selection.load_balance_policies") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "router_path_selection.load_balance_policies.[].name") | String | Required, Unique | | | Load-balance policy name. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_groups</samp>](## "router_path_selection.load_balance_policies.[].path_groups") | List, items: String | | | | List of path-groups to use for this load balance policy. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "router_path_selection.load_balance_policies.[].path_groups.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lowest_hop_count</samp>](## "router_path_selection.load_balance_policies.[].lowest_hop_count") | Boolean | | | | Prefer paths with lowest hop-count. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jitter</samp>](## "router_path_selection.load_balance_policies.[].jitter") | Integer | | | Min: 0<br>Max: 10000 | Jitter requirement for this load balance policy in milliseconds. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latency</samp>](## "router_path_selection.load_balance_policies.[].latency") | Integer | | | Min: 0<br>Max: 10000 | One way delay requirement for this load balance policy in milliseconds. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loss_rate</samp>](## "router_path_selection.load_balance_policies.[].loss_rate") | String | | | Pattern: ^\d+(\.\d{1,2})?$ | Loss Rate requirement in percentage for this load balance policy.<br>Value between 0.00 and 100.00 % |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_groups</samp>](## "router_path_selection.load_balance_policies.[].path_groups") | List, items: Dictionary | | | | List of path-groups to use for this load balance policy. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "router_path_selection.load_balance_policies.[].path_groups.[].name") | String | Required, Unique | | | Path-group name |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;priority</samp>](## "router_path_selection.load_balance_policies.[].path_groups.[].priority") | Integer | | | Min: 1<br>Max: 65535 | Priority for this path-group.<br>The EOS default value is 1. |
| [<samp>&nbsp;&nbsp;policies</samp>](## "router_path_selection.policies") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "router_path_selection.policies.[].name") | String | Required, Unique | | | DPS policy name. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_match</samp>](## "router_path_selection.policies.[].default_match") | Dictionary | | | | |
Expand Down Expand Up @@ -122,9 +127,28 @@
# Load-balance policy name.
- name: <str; required; unique>

# Prefer paths with lowest hop-count.
lowest_hop_count: <bool>

# Jitter requirement for this load balance policy in milliseconds.
jitter: <int; 0-10000>

# One way delay requirement for this load balance policy in milliseconds.
latency: <int; 0-10000>

# Loss Rate requirement in percentage for this load balance policy.
# Value between 0.00 and 100.00 %
loss_rate: <str>

# List of path-groups to use for this load balance policy.
path_groups:
- <str>

# Path-group name
- name: <str; required; unique>

# Priority for this path-group.
# The EOS default value is 1.
priority: <int; 1-65535>
policies:

# DPS policy name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20651,11 +20651,57 @@
"description": "Load-balance policy name.",
"title": "Name"
},
"lowest_hop_count": {
"type": "boolean",
"description": "Prefer paths with lowest hop-count.",
"title": "Lowest Hop Count"
},
"jitter": {
"type": "integer",
"description": "Jitter requirement for this load balance policy in milliseconds.",
"minimum": 0,
"maximum": 10000,
"title": "Jitter"
},
"latency": {
"type": "integer",
"description": "One way delay requirement for this load balance policy in milliseconds.",
"minimum": 0,
"maximum": 10000,
"title": "Latency"
},
"loss_rate": {
"type": "string",
"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"
},
"path_groups": {
"type": "array",
"description": "List of path-groups to use for this load balance policy.",
"items": {
"type": "string"
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Path-group name",
"title": "Name"
},
"priority": {
"type": "integer",
"description": "Priority for this path-group.\nThe EOS default value is 1.",
"minimum": 1,
"maximum": 65535,
"title": "Priority"
}
},
"additionalProperties": false,
"patternProperties": {
"^_.+$": {}
},
"required": [
"name"
]
},
"title": "Path Groups"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11830,11 +11830,53 @@ keys:
name:
type: str
description: Load-balance policy name.
lowest_hop_count:
type: bool
description: Prefer paths with lowest hop-count.
jitter:
type: int
description: Jitter requirement for this load balance policy in milliseconds.
convert_types:
- str
min: 0
max: 10000
latency:
type: int
description: One way delay requirement for this load balance policy
in milliseconds.
convert_types:
- str
min: 0
max: 10000
loss_rate:
type: str
description: 'Loss Rate requirement in percentage for this load balance
policy.
Value between 0.00 and 100.00 %'
convert_types:
- int
- float
pattern: ^\d+(\.\d{1,2})?$
path_groups:
type: list
primary_key: name
description: List of path-groups to use for this load balance policy.
items:
type: str
type: dict
keys:
name:
type: str
description: Path-group name
priority:
type: int
description: 'Priority for this path-group.
The EOS default value is 1.'
convert_types:
- str
min: 1
max: 65535
policies:
type: list
primary_key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,51 @@ keys:
name:
type: str
description: Load-balance policy name.
lowest_hop_count:
type: bool
description: Prefer paths with lowest hop-count.
jitter:
type: int
description: Jitter requirement for this load balance policy in milliseconds.
convert_types:
- str
min: 0
max: 10000
latency:
type: int
description: One way delay requirement for this load balance policy in milliseconds.
convert_types:
- str
min: 0
max: 10000
loss_rate:
type: str
description: |-
Loss Rate requirement in percentage for this load balance policy.
Value between 0.00 and 100.00 %
convert_types:
- int
- float
pattern: "^\\d+(\\.\\d{1,2})?$"
path_groups:
type: list
primary_key: name
description: List of path-groups to use for this load balance policy.
items:
type: str
type: dict
keys:
name:
type: str
description: Path-group name
priority:
type: int
description: |-
Priority for this path-group.
The EOS default value is 1.
convert_types:
- str
min: 1
max: 65535
policies:
type: list
primary_key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,24 @@

#### Load-balance policies

| Policy name | Path group(s) |
| ----------- | ------------- |
| Policy Name | Jitter (ms) | Latency (ms) | Loss Rate (%) | Path Groups (priority) | Lowest Hop Count |
| ----------- | ----------- | ------------ | ------------- | ---------------------- | ---------------- |
{% for load_balance_policy in router_path_selection.load_balance_policies | arista.avd.natural_sort('name') %}
| {{ load_balance_policy.name }} | {{ load_balance_policy.path_groups | arista.avd.natural_sort() | join("<br>") }} |
{% set lowest_hop_count = load_balance_policy.lowest_hop_count | arista.avd.default(false) %}
{% set jitter = load_balance_policy.jitter | arista.avd.default("-") %}
{% set latency = load_balance_policy.latency | arista.avd.default("-") %}
{% set loss_rate = load_balance_policy.loss_rate | arista.avd.default("-") %}
{% set path_groups_list = [] %}
{# 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([]) %}
{% 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 entry in entries | arista.avd.natural_sort("name") %}
{% do path_groups_list.append(entry.name ~ " (" ~ priority ~ ")") %}
{% endfor %}
{% endfor %}
| {{ load_balance_policy.name }} | {{ jitter }} | {{ latency }} | {{ loss_rate }} | {{ path_groups_list | join("<br>") }} | {{ lowest_hop_count }} |
{% endfor %}
{% endif %}
{% if router_path_selection.policies is arista.avd.defined %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,30 @@ router path-selection
{% for load_balance_policy in router_path_selection.load_balance_policies | arista.avd.natural_sort('name') %}
!
load-balance policy {{ load_balance_policy.name }}
{% for path_group_name in load_balance_policy.path_groups | arista.avd.default([]) %}
path-group {{ path_group_name }}
{% if load_balance_policy.lowest_hop_count is arista.avd.defined(true) %}
hop count lowest
{% endif %}
{% if load_balance_policy.jitter is arista.avd.defined %}
jitter {{ load_balance_policy.jitter }}
{% endif %}
{% if load_balance_policy.latency is arista.avd.defined %}
latency {{ load_balance_policy.latency }}
{% endif %}
{% if load_balance_policy.loss_rate is arista.avd.defined %}
loss-rate {{ load_balance_policy.loss_rate }}
{% 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([]) %}
{% 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 entry in entries | arista.avd.natural_sort("name") %}
{% set path_group_cli = "path-group " ~ entry.name %}
{% if entry.priority is arista.avd.defined %}
{% set path_group_cli = path_group_cli ~ " priority " ~ entry.priority %}
{% endif %}
{{ path_group_cli }}
{% endfor %}
{% endfor %}
{% endfor %}
{# DPS policies #}
Expand Down

0 comments on commit 3557bbe

Please sign in to comment.