Skip to content

Commit

Permalink
Feat(eos_cli_config_gen): Extend match lists to support IPv4 and IPv6 (
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmacgiolla authored Mar 26, 2024
1 parent 9d2b38a commit 2a2c73f
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ interface Management1

### Match-lists

#### Match-list Input IPv4-prefix Summary

| Prefix List Name | Prefixes |
| ---------------- | -------- |
| molecule_v4 | 10.10.10.0/24, 10.10.20.0/24 |

#### Match-list Input IPv6-prefix Summary

| Prefix List Name | Prefixes |
| ---------------- | -------- |
| molecule_v6 | 2001:0DB8::/32 |

#### Match-list Input String Summary

##### molecule
Expand All @@ -52,6 +64,13 @@ interface Management1

```eos
!
match-list input prefix-ipv4 molecule_v4
match prefix-ipv4 10.10.10.0/24
match prefix-ipv4 10.10.20.0/24
!
match-list input prefix-ipv6 molecule_v6
match prefix-ipv6 2001:0DB8::/32
!
match-list input string molecule
10 match regex ^.*MOLECULE.*$
20 match regex ^.*TESTING.*$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
!
transceiver qsfp default-mode 4x10G
!
match-list input prefix-ipv4 molecule_v4
match prefix-ipv4 10.10.10.0/24
match prefix-ipv4 10.10.20.0/24
!
match-list input prefix-ipv6 molecule_v6
match prefix-ipv6 2001:0DB8::/32
!
match-list input string molecule
10 match regex ^.*MOLECULE.*$
20 match regex ^.*TESTING.*$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
match_list_input:
prefix_ipv4:
- name: molecule_v4
prefixes:
- 10.10.10.0/24
- 10.10.20.0/24
prefix_ipv6:
- name: molecule_v6
prefixes:
- 2001:0DB8::/32
string:
- name: molecule
sequence_numbers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
| Variable | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| [<samp>match_list_input</samp>](## "match_list_input") | Dictionary | | | | |
| [<samp>&nbsp;&nbsp;prefix_ipv4</samp>](## "match_list_input.prefix_ipv4") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "match_list_input.prefix_ipv4.[].name") | String | Required, Unique | | | Prefix-List Name. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefixes</samp>](## "match_list_input.prefix_ipv4.[].prefixes") | List, items: String | Required | | Min Length: 1 | List of IPv4 prefixes (with the subnet mask e.g. 192.0.2.0/24). |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "match_list_input.prefix_ipv4.[].prefixes.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;prefix_ipv6</samp>](## "match_list_input.prefix_ipv6") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "match_list_input.prefix_ipv6.[].name") | String | Required, Unique | | | Prefix-List Name. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefixes</samp>](## "match_list_input.prefix_ipv6.[].prefixes") | List, items: String | Required | | Min Length: 1 | List of IPv6 prefixes (with the subnet mask e.g. 2001:db8:abcd:0013::/64). |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "match_list_input.prefix_ipv6.[].prefixes.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;string</samp>](## "match_list_input.string") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "match_list_input.string.[].name") | String | Required, Unique | | | Match-list Name |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sequence_numbers</samp>](## "match_list_input.string.[].sequence_numbers") | List, items: Dictionary | Required | | | |
Expand All @@ -18,6 +26,22 @@

```yaml
match_list_input:
prefix_ipv4:

# Prefix-List Name.
- name: <str; required; unique>

# List of IPv4 prefixes (with the subnet mask e.g. 192.0.2.0/24).
prefixes: # >=1 items; required
- <str>
prefix_ipv6:

# Prefix-List Name.
- name: <str; required; unique>

# List of IPv6 prefixes (with the subnet mask e.g. 2001:db8:abcd:0013::/64).
prefixes: # >=1 items; required
- <str>
string:

# Match-list Name
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 @@ -10,6 +10,38 @@ keys:
type: dict
display_name: Match Lists
keys:
prefix_ipv4:
type: list
primary_key: name
items:
type: dict
keys:
name:
type: str
description: Prefix-List Name.
prefixes:
type: list
required: true
min_length: 1
description: List of IPv4 prefixes (with the subnet mask e.g. 192.0.2.0/24).
items:
type: str
prefix_ipv6:
type: list
primary_key: name
items:
type: dict
keys:
name:
type: str
description: Prefix-List Name.
prefixes:
type: list
required: true
min_length: 1
description: List of IPv6 prefixes (with the subnet mask e.g. 2001:db8:abcd:0013::/64).
items:
type: str
string:
type: list
primary_key: name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,28 @@
{% if match_list_input is arista.avd.defined %}

### Match-lists
{% if match_list_input.prefix_ipv4 is arista.avd.defined %}

#### Match-list Input IPv4-prefix Summary

| Prefix List Name | Prefixes |
| ---------------- | -------- |
{% for match_list in match_list_input.prefix_ipv4 %}
| {{ match_list.name }} | {{ match_list.prefixes | arista.avd.default(['-']) | join(', ') }} |
{% endfor %}
{% endif %}
{% if match_list_input.prefix_ipv6 is arista.avd.defined %}

#### Match-list Input IPv6-prefix Summary

| Prefix List Name | Prefixes |
| ---------------- | -------- |
{% for match_list in match_list_input.prefix_ipv6 %}
| {{ match_list.name }} | {{ match_list.prefixes | arista.avd.default(['-']) | join(', ') }} |
{% endfor %}
{% endif %}
{% if match_list_input.string is arista.avd.defined %}

#### Match-list Input String Summary

{% for match_list in match_list_input.string | arista.avd.natural_sort('name') %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,33 @@
#}
{# eos - match list input #}
{% if match_list_input is arista.avd.defined %}
{% if match_list_input.prefix_ipv4 is arista.avd.defined %}
!
{% for match_list in match_list_input.string | arista.avd.natural_sort('name') %}
{% for match_list in match_list_input.prefix_ipv4 | arista.avd.natural_sort('name') %}
match-list input prefix-ipv4 {{ match_list.name }}
{% for entry in match_list.prefixes %}
match prefix-ipv4 {{ entry }}
{% endfor %}
{% endfor %}
{% endif %}
{% if match_list_input.prefix_ipv6 is arista.avd.defined %}
!
{% for match_list in match_list_input.prefix_ipv6 | arista.avd.natural_sort('name') %}
match-list input prefix-ipv6 {{ match_list.name }}
{% for entry in match_list.prefixes %}
match prefix-ipv6 {{ entry }}
{% endfor %}
{% endfor %}
{% endif %}
{% if match_list_input.string is arista.avd.defined %}
!
{% for match_list in match_list_input.string | arista.avd.natural_sort('name') %}
match-list input string {{ match_list.name }}
{% for sequence in match_list.sequence_numbers | arista.avd.natural_sort('sequence') %}
{% if sequence.match_regex is arista.avd.defined %}
{% for sequence in match_list.sequence_numbers | arista.avd.natural_sort('sequence') %}
{% if sequence.match_regex is arista.avd.defined %}
{{ sequence.sequence }} match regex {{ sequence.match_regex }}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}

0 comments on commit 2a2c73f

Please sign in to comment.