From e1d02df790babed4e2e08fb69cd8bea3c4d4934b Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Fri, 17 Nov 2023 10:26:01 +0100 Subject: [PATCH 1/4] Fix(eos_cli_config_gen): BGP VRF Prefix-lists not allowed outside of AF --- .../devices/router-bgp-vrf-lite.md | 6 ++- .../intended/configs/router-bgp-vrf-lite.cfg | 6 ++- .../host_vars/router-bgp-vrf-lite.yml | 7 +++- .../documentation/devices/host1.md | 12 ++++++ .../intended/configs/host1.cfg | 10 +++++ .../inventory/host_vars/host1/router-bgp.yml | 27 ++++++++++++ .../docs/tables/router-bgp.md | 22 ++++++++-- .../eos_cli_config_gen.jsonschema.json | 16 +++++++- .../schemas/eos_cli_config_gen.schema.yml | 16 +++++++- .../schema_fragments/router_bgp.schema.yml | 16 +++++++- .../templates/eos/router-bgp.j2 | 41 +++++++++++++++++-- 11 files changed, 162 insertions(+), 17 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md index c9654cbf5f6..b002e0ed075 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md @@ -225,8 +225,10 @@ router bgp 65001 vrf RED-C1 rd 1.0.1.1:102 neighbor 10.1.1.0 peer group OBS_WAN - neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in - neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out + ! + address-family ipv4 + neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in + neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out ! vrf YELLOW-C1 rd 1.0.1.1:103 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg index 674dc1d57b7..9c681b1160a 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg @@ -105,8 +105,10 @@ router bgp 65001 vrf RED-C1 rd 1.0.1.1:102 neighbor 10.1.1.0 peer group OBS_WAN - neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in - neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out + ! + address-family ipv4 + neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in + neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out ! vrf YELLOW-C1 rd 1.0.1.1:103 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml index 00f03d78b36..39ca6f9fc02 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml @@ -149,8 +149,11 @@ router_bgp: neighbors: - ip_address: 10.1.1.0 peer_group: OBS_WAN - prefix_list_in: PL-BGP-DEFAULT-RED-IN-C1 - prefix_list_out: PL-BGP-DEFAULT-RED-OUT-C1 + address_family_ipv4: + neighbors: + - ip_address: 10.1.1.0 + prefix_list_in: PL-BGP-DEFAULT-RED-IN-C1 + prefix_list_out: PL-BGP-DEFAULT-RED-OUT-C1 - name: YELLOW-C1 rd: 1.0.1.1:103 listen_ranges: diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md index 778c69e0823..6ec62ecbccc 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md @@ -1066,6 +1066,8 @@ router isis EVPN_UNDERLAY | 192.168.255.1 | Inherited from peer group EVPN-OVERLAY-PEERS | default | - | - | - | - | - | - | - | - | | 192.168.255.2 | Inherited from peer group EVPN-OVERLAY-PEERS | default | - | - | - | - | - | - | - | - | | 10.255.251.1 | Inherited from peer group EVPN-OVERLAY-PEERS | TENANT_A_PROJECT01 | - | - | - | - | - | - | - | - | +| 10.2.3.4 | - | TENANT_A_PROJECT01 | - | - | - | - | - | - | - | - | +| 10.2.3.5 | - | TENANT_A_PROJECT01 | - | - | - | - | - | - | - | - | #### BGP Neighbor Interfaces @@ -1210,6 +1212,16 @@ router bgp 65101 redistribute connected redistribute static route-map RM-CONN-2-BGP ! + address-family ipv4 + neighbor 10.2.3.4 activate + neighbor 10.2.3.4 prefix-list PL-TEST-IN-AF4 in + neighbor 10.2.3.4 prefix-list PL-TEST-OUT-AF4 out + neighbor 10.2.3.5 activate + neighbor 10.2.3.5 prefix-list PL-TEST-IN in + neighbor 10.2.3.5 prefix-list PL-TEST-OUT out + neighbor 10.255.251.1 prefix-list PL-TEST-IN in + neighbor 10.255.251.1 prefix-list PL-TEST-OUT out + ! address-family ipv4 neighbor TEST_PEER_GRP activate neighbor 10.2.3.4 activate diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg index 5dd6fa854f9..07da1906dd3 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg @@ -516,6 +516,16 @@ router bgp 65101 redistribute connected redistribute static route-map RM-CONN-2-BGP ! + address-family ipv4 + neighbor 10.2.3.4 activate + neighbor 10.2.3.4 prefix-list PL-TEST-IN-AF4 in + neighbor 10.2.3.4 prefix-list PL-TEST-OUT-AF4 out + neighbor 10.2.3.5 activate + neighbor 10.2.3.5 prefix-list PL-TEST-IN in + neighbor 10.2.3.5 prefix-list PL-TEST-OUT out + neighbor 10.255.251.1 prefix-list PL-TEST-IN in + neighbor 10.255.251.1 prefix-list PL-TEST-OUT out + ! address-family ipv4 neighbor TEST_PEER_GRP activate neighbor 10.2.3.4 activate diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/router-bgp.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/router-bgp.yml index 195e724efff..dfd0cd80811 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/router-bgp.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/router-bgp.yml @@ -142,6 +142,33 @@ router_bgp: neighbors: 10.255.251.1: peer_group: EVPN-OVERLAY-PEERS + # prefix_list_in is deprecated in 4.5.0. To be removed in 5.0.0 + prefix_list_in: PL-TEST-IN + # prefix_list_out is deprecated in 4.5.0. To be removed in 5.0.0 + prefix_list_out: PL-TEST-OUT + 10.2.3.4: + # prefix_list_in is deprecated in 4.5.0. To be removed in 5.0.0 + # Testing overlap with address family (should be ignored) + prefix_list_in: PL-TEST-IN + # prefix_list_out is deprecated in 4.5.0. To be removed in 5.0.0 + # Testing overlap with address family (should be ignored) + prefix_list_out: PL-TEST-OUT + 10.2.3.5: + # prefix_list_in is deprecated in 4.5.0. To be removed in 5.0.0 + # Testing existing in AF but not overlapping (should get configured) + prefix_list_in: PL-TEST-IN + # prefix_list_out is deprecated in 4.5.0. To be removed in 5.0.0 + # Testing existing in AF but not overlapping (should get configured) + prefix_list_out: PL-TEST-OUT + # Part of test of overlaps from VRF neighbors. To be removed in 5.0.0 + address_family_ipv4: + neighbors: + - ip_address: 10.2.3.4 + activate: true + prefix_list_in: PL-TEST-IN-AF4 + prefix_list_out: PL-TEST-OUT-AF4 + - ip_address: 10.2.3.5 + activate: true # Testing neighbors as dict of dict # Dict type is deprecated in 4.0.0. To be removed in 5.0.0 redistribute_routes: diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index ed38df856c1..397f6200629 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -561,8 +561,8 @@ | [          update_source](## "router_bgp.vrfs.[].neighbors.[].update_source") | String | | | | | | [          route_map_in](## "router_bgp.vrfs.[].neighbors.[].route_map_in") | String | | | | Inbound route-map name | | [          route_map_out](## "router_bgp.vrfs.[].neighbors.[].route_map_out") | String | | | | Outbound route-map name | - | [          prefix_list_in](## "router_bgp.vrfs.[].neighbors.[].prefix_list_in") | String | | | | Inbound prefix-list name | - | [          prefix_list_out](## "router_bgp.vrfs.[].neighbors.[].prefix_list_out") | String | | | | Outbound prefix-list name | + | [          prefix_list_in](## "router_bgp.vrfs.[].neighbors.[].prefix_list_in") deprecated | String | | | | Inbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead. | + | [          prefix_list_out](## "router_bgp.vrfs.[].neighbors.[].prefix_list_out") deprecated | String | | | | Outbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead. | | [      neighbor_interfaces](## "router_bgp.vrfs.[].neighbor_interfaces") | List, items: Dictionary | | | | | | [        - name](## "router_bgp.vrfs.[].neighbor_interfaces.[].name") | String | Required, Unique | | | Interface name | | [          remote_as](## "router_bgp.vrfs.[].neighbor_interfaces.[].remote_as") | String | | | | BGP AS <1-4294967295> or AS number in asdot notation "<1-65535>.<0-65535>" | @@ -600,6 +600,8 @@ | [            activate](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].activate") | Boolean | | | | | | [            route_map_in](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].route_map_in") | String | | | | Inbound route-map name | | [            route_map_out](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].route_map_out") | String | | | | Outbound route-map name | + | [            prefix_list_in](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].prefix_list_in") | String | | | | Inbound prefix-list name | + | [            prefix_list_out](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].prefix_list_out") | String | | | | Outbound prefix-list name | | [            next_hop](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].next_hop") | Dictionary | | | | | | [              address_family_ipv6](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].next_hop.address_family_ipv6") | Dictionary | | | | | | [                enabled](## "router_bgp.vrfs.[].address_family_ipv4.neighbors.[].next_hop.address_family_ipv6.enabled") | Boolean | Required | | | | @@ -676,7 +678,7 @@ | [        neighbors](## "router_bgp.vrfs.[].address_family_flow_spec_ipv6.neighbors") | List, items: Dictionary | | | | | | [          - ip_address](## "router_bgp.vrfs.[].address_family_flow_spec_ipv6.neighbors.[].ip_address") | String | Required, Unique | | | | | [            activate](## "router_bgp.vrfs.[].address_family_flow_spec_ipv6.neighbors.[].activate") | Boolean | | | | | - | [      address_families](## "router_bgp.vrfs.[].address_families") deprecated | List, items: Dictionary | | | | This key is deprecated. Support will be removed in AVD version v5.0.0. Use address_family_* instead. | + | [      address_families](## "router_bgp.vrfs.[].address_families") deprecated | List, items: Dictionary | | | | This key is deprecated. Support will be removed in AVD version 5.0.0. Use address_family_* instead. | | [        - address_family](## "router_bgp.vrfs.[].address_families.[].address_family") | String | Required, Unique | | | | | [          bgp](## "router_bgp.vrfs.[].address_families.[].bgp") | Dictionary | | | | | | [            missing_policy](## "router_bgp.vrfs.[].address_families.[].bgp.missing_policy") | Dictionary | | | | | @@ -1646,9 +1648,15 @@ route_map_out: # Inbound prefix-list name + # This key is deprecated. + # Support will be removed in AVD version 5.0.0. + # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead. prefix_list_in: # Outbound prefix-list name + # This key is deprecated. + # Support will be removed in AVD version 5.0.0. + # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead. prefix_list_out: neighbor_interfaces: @@ -1705,6 +1713,12 @@ # Outbound route-map name route_map_out: + + # Inbound prefix-list name + prefix_list_in: + + # Outbound prefix-list name + prefix_list_out: next_hop: address_family_ipv6: enabled: @@ -1806,7 +1820,7 @@ - ip_address: activate: # This key is deprecated. - # Support will be removed in AVD version v5.0.0. + # Support will be removed in AVD version 5.0.0. # Use address_family_* instead. address_families: - address_family: 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 2e0ce171eb1..66eb39150eb 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 @@ -17753,12 +17753,14 @@ }, "prefix_list_in": { "type": "string", - "description": "Inbound prefix-list name", + "description": "Inbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead.", + "deprecated": true, "title": "Prefix List In" }, "prefix_list_out": { "type": "string", - "description": "Outbound prefix-list name", + "description": "Outbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead.", + "deprecated": true, "title": "Prefix List Out" } }, @@ -18003,6 +18005,16 @@ "description": "Outbound route-map name", "title": "Route Map Out" }, + "prefix_list_in": { + "type": "string", + "description": "Inbound prefix-list name", + "title": "Prefix List In" + }, + "prefix_list_out": { + "type": "string", + "description": "Outbound prefix-list name", + "title": "Prefix List Out" + }, "next_hop": { "type": "object", "properties": { 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 9c3a76c98e7..f38a29cc739 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 @@ -10305,9 +10305,17 @@ keys: prefix_list_in: type: str description: Inbound prefix-list name + deprecation: + warning: true + new_key: router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in + remove_in_version: 5.0.0 prefix_list_out: type: str description: Outbound prefix-list name + deprecation: + warning: true + new_key: router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out + remove_in_version: 5.0.0 neighbor_interfaces: type: list primary_key: name @@ -10440,6 +10448,12 @@ keys: route_map_out: type: str description: Outbound route-map name + prefix_list_in: + type: str + description: Inbound prefix-list name + prefix_list_out: + type: str + description: Outbound prefix-list name next_hop: type: dict keys: @@ -10736,7 +10750,7 @@ keys: deprecation: warning: true new_key: address_family_* - remove_in_version: v5.0.0 + remove_in_version: 5.0.0 items: type: dict keys: diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml index 915047591fc..fce2496a504 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml @@ -1961,9 +1961,17 @@ keys: prefix_list_in: type: str description: Inbound prefix-list name + deprecation: + warning: true + new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in" + remove_in_version: 5.0.0 prefix_list_out: type: str description: Outbound prefix-list name + deprecation: + warning: true + new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out" + remove_in_version: 5.0.0 neighbor_interfaces: type: list primary_key: name @@ -2095,6 +2103,12 @@ keys: route_map_out: type: str description: Outbound route-map name + prefix_list_in: + type: str + description: Inbound prefix-list name + prefix_list_out: + type: str + description: Outbound prefix-list name next_hop: type: dict keys: @@ -2391,7 +2405,7 @@ keys: deprecation: warning: true new_key: address_family_* - remove_in_version: v5.0.0 + remove_in_version: 5.0.0 items: type: dict keys: diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 index 3e5da227419..ffba8a0dc93 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 @@ -1210,6 +1210,12 @@ router bgp {{ router_bgp.as }} neighbor interface {{ neighbor_interface.name }} peer-group {{ neighbor_interface.peer_group }} peer-filter {{ neighbor_interface.peer_filter }} {% endif %} {% endfor %} +{# TODO: AVD5.0 remove tmp_vrf_neighbor_prefix_list_in and tmp_vrf_neighbor_prefix_list_out #} +{# Special temporary variables set under vrf neighbors but read under vrf address_family_ipv4 #} +{# This is required to move the deprecated vrfs[].neighbors[].ip_prefix_list_in/out to #} +{# vrfs[].address_family_ipv4.neighbors[].ip_prefix_list_in/out #} +{% set tmp_vrf_neighbor_prefix_list_in = {} %} +{% set tmp_vrf_neighbor_prefix_list_out = {} %} {% for neighbor in vrf.neighbors | arista.avd.natural_sort('ip_address') %} {% if neighbor.remote_as is arista.avd.defined %} neighbor {{ neighbor.ip_address }} remote-as {{ neighbor.remote_as }} @@ -1336,11 +1342,15 @@ router bgp {{ router_bgp.as }} {% if neighbor.route_map_in is arista.avd.defined %} neighbor {{ neighbor.ip_address }} route-map {{ neighbor.route_map_in }} in {% endif %} +{# TODO: AVD5.0 remove tmp_vrf_neighbor_prefix_list_in and tmp_vrf_neighbor_prefix_list_out #} +{# Special temporary variables set under vrf neighbors but read under vrf address_family_ipv4 #} +{# This is required to move the deprecated vrfs[].neighbors[].ip_prefix_list_in/out to #} +{# vrfs[].address_family_ipv4.neighbors[].ip_prefix_list_in/out #} {% if neighbor.prefix_list_in is arista.avd.defined %} - neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_in }} in +{% do tmp_vrf_neighbor_prefix_list_in.update({neighbor.ip_address: neighbor.prefix_list_in}) %} {% endif %} {% if neighbor.prefix_list_out is arista.avd.defined %} - neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_out }} out +{% do tmp_vrf_neighbor_prefix_list_out.update({neighbor.ip_address: neighbor.prefix_list_out}) %} {% endif %} {% endfor %} {% for network in vrf.networks | arista.avd.natural_sort('prefix') %} @@ -1411,7 +1421,8 @@ router bgp {{ router_bgp.as }} {% endif %} {% endfor %} {% endif %} -{% if vrf.address_family_ipv4 is arista.avd.defined %} +{# TODO: AVD5.0 remove tmp_vrf_neighbor_prefix_list_in and tmp_vrf_neighbor_prefix_list_out #} +{% if vrf.address_family_ipv4 is arista.avd.defined or tmp_vrf_neighbor_prefix_list_in or tmp_vrf_neighbor_prefix_list_out %} ! address-family ipv4 {% if vrf.address_family_ipv4.bgp.missing_policy.direction_in_action is arista.avd.defined %} @@ -1449,6 +1460,23 @@ router bgp {{ router_bgp.as }} {% if neighbor.route_map_out is arista.avd.defined %} neighbor {{ neighbor.ip_address }} route-map {{ neighbor.route_map_out }} out {% endif %} +{# TODO: AVD5.0 remove tmp_vrf_neighbor_prefix_list_in and tmp_vrf_neighbor_prefix_list_out #} +{% if neighbor.prefix_list_in is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_in }} in +{% if tmp_vrf_neighbor_prefix_list_in[neighbor.ip_address] is arista.avd.defined %} +{% do tmp_vrf_neighbor_prefix_list_in.pop(neighbor.ip_address) %} +{% endif %} +{% elif tmp_vrf_neighbor_prefix_list_in[neighbor.ip_address] is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ tmp_vrf_neighbor_prefix_list_in.pop(neighbor.ip_address) }} in +{% endif %} +{% if neighbor.prefix_list_out is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_out }} out +{% if tmp_vrf_neighbor_prefix_list_out[neighbor.ip_address] is arista.avd.defined %} +{% do tmp_vrf_neighbor_prefix_list_out.pop(neighbor.ip_address) %} +{% endif %} +{% elif tmp_vrf_neighbor_prefix_list_out[neighbor.ip_address] is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ tmp_vrf_neighbor_prefix_list_out.pop(neighbor.ip_address) }} out +{% endif %} {% if neighbor.next_hop.address_family_ipv6.enabled is arista.avd.defined %} {% if neighbor.next_hop.address_family_ipv6.enabled is arista.avd.defined(true) %} {% set ipv6_originate_cli = "neighbor " ~ neighbor.ip_address ~ " next-hop address-family ipv6" %} @@ -1461,6 +1489,13 @@ router bgp {{ router_bgp.as }} {{ ipv6_originate_cli }} {% endif %} {% endfor %} +{# TODO: AVD5.0 remove tmp_vrf_neighbor_prefix_list_in and tmp_vrf_neighbor_prefix_list_out #} +{% for tmp_neighbor_ip in tmp_vrf_neighbor_prefix_list_in | arista.avd.natural_sort %} + neighbor {{ tmp_neighbor_ip }} prefix-list {{ tmp_vrf_neighbor_prefix_list_in[tmp_neighbor_ip] }} in +{% endfor %} +{% for tmp_neighbor_ip in tmp_vrf_neighbor_prefix_list_out | arista.avd.natural_sort %} + neighbor {{ tmp_neighbor_ip }} prefix-list {{ tmp_vrf_neighbor_prefix_list_out[tmp_neighbor_ip] }} out +{% endfor %} {% for network in vrf.address_family_ipv4.networks | arista.avd.natural_sort('prefix') %} {% set network_cli = "network " ~ network.prefix %} {% if network.route_map is arista.avd.defined %} From 60d50111d6a3d671421a7cdfc336b6bab512f3fa Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Fri, 17 Nov 2023 12:32:52 +0100 Subject: [PATCH 2/4] Fix(eos_designs): Fix support for prefix_list_in/out under network services --- .../inventory/host_vars/router-bgp-vrf-lite.yml | 5 +++++ .../intended/configs/DC1-BL1A.cfg | 4 ++++ .../intended/configs/DC1-BL1B.cfg | 4 ++++ .../intended/structured_configs/DC1-BL1A.yml | 4 ++++ .../intended/structured_configs/DC1-BL1B.yml | 4 ++++ .../group_vars/DC1_TENANTS_NETWORKS/Tenant_A.yml | 4 ++++ .../roles/eos_cli_config_gen/docs/tables/router-bgp.md | 8 ++++++++ .../schemas/eos_cli_config_gen.jsonschema.json | 10 ++++++++++ .../schemas/eos_cli_config_gen.schema.yml | 6 ++++++ .../schemas/schema_fragments/router_bgp.schema.yml | 6 ++++++ .../eos_cli_config_gen/templates/eos/router-bgp.j2 | 6 ++++++ .../docs/tables/network-services-vrfs-bgp-settings.md | 10 ++++++---- .../python_modules/network_services/router_bgp.py | 9 ++++++++- .../roles/eos_designs/schemas/eos_designs.schema.yml | 10 ++++++++-- .../schema_fragments/defs_network_services.schema.yml | 8 ++++++-- 15 files changed, 89 insertions(+), 9 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml index 39ca6f9fc02..ac6dfa8d4a9 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/router-bgp-vrf-lite.yml @@ -154,6 +154,11 @@ router_bgp: - ip_address: 10.1.1.0 prefix_list_in: PL-BGP-DEFAULT-RED-IN-C1 prefix_list_out: PL-BGP-DEFAULT-RED-OUT-C1 + address_family_ipv6: + neighbors: + - ip_address: 2001:cafe:192:168::4 + prefix_list_in: PL-BGP-V6-RED-IN-C1 + prefix_list_out: PL-BGP-V6-RED-OUT-C1 - name: YELLOW-C1 rd: 1.0.1.1:103 listen_ranges: diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg index 867771846ee..bc5d144d226 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg @@ -387,9 +387,13 @@ router bgp 65104 address-family ipv4 neighbor 123.1.1.10 activate neighbor 123.1.1.11 activate + neighbor 123.1.1.11 prefix-list PL-TEST-IN-AF4 in + neighbor 123.1.1.11 prefix-list PL-TEST-OUT-AF4 out ! address-family ipv6 neighbor fd5a:fe45:8831:06c5::a activate + neighbor fd5a:fe45:8831:06c5::a prefix-list PL-TEST-IN-AF6 in + neighbor fd5a:fe45:8831:06c5::a prefix-list PL-TEST-OUT-AF6 out neighbor fd5a:fe45:8831:06c5::b activate ! vrf Tenant_B_OP_Zone diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1B.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1B.cfg index 40b39860691..90a8be0f9d1 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1B.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1B.cfg @@ -368,9 +368,13 @@ router bgp 65105 address-family ipv4 neighbor 123.1.1.10 activate neighbor 123.1.1.11 activate + neighbor 123.1.1.11 prefix-list PL-TEST-IN-AF4 in + neighbor 123.1.1.11 prefix-list PL-TEST-OUT-AF4 out ! address-family ipv6 neighbor fd5a:fe45:8831:06c5::a activate + neighbor fd5a:fe45:8831:06c5::a prefix-list PL-TEST-IN-AF6 in + neighbor fd5a:fe45:8831:06c5::a prefix-list PL-TEST-OUT-AF6 out neighbor fd5a:fe45:8831:06c5::b activate ! vrf Tenant_B_OP_Zone diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml index 9c985d1a2e6..49468d38ae4 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml @@ -158,6 +158,8 @@ router_bgp: activate: true - ip_address: 123.1.1.11 activate: true + prefix_list_in: PL-TEST-IN-AF4 + prefix_list_out: PL-TEST-OUT-AF4 neighbors: - ip_address: 123.1.1.10 remote_as: '1234' @@ -198,6 +200,8 @@ router_bgp: neighbors: - ip_address: fd5a:fe45:8831:06c5::a activate: true + prefix_list_in: PL-TEST-IN-AF6 + prefix_list_out: PL-TEST-OUT-AF6 - ip_address: fd5a:fe45:8831:06c5::b activate: true updates: diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml index 196218c6baa..2e078ec976b 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml @@ -163,6 +163,8 @@ router_bgp: activate: true - ip_address: 123.1.1.11 activate: true + prefix_list_in: PL-TEST-IN-AF4 + prefix_list_out: PL-TEST-OUT-AF4 neighbors: - ip_address: 123.1.1.10 remote_as: '1234' @@ -203,6 +205,8 @@ router_bgp: neighbors: - ip_address: fd5a:fe45:8831:06c5::a activate: true + prefix_list_in: PL-TEST-IN-AF6 + prefix_list_out: PL-TEST-OUT-AF6 - ip_address: fd5a:fe45:8831:06c5::b activate: true updates: diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/DC1_TENANTS_NETWORKS/Tenant_A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/DC1_TENANTS_NETWORKS/Tenant_A.yml index 1c41d3c8738..e935993d306 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/DC1_TENANTS_NETWORKS/Tenant_A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/group_vars/DC1_TENANTS_NETWORKS/Tenant_A.yml @@ -182,6 +182,8 @@ tenant_a: nodes: [DC1-BL1A, DC1-BL1B] route_map_in: RM-123-1-1-11-IN route_map_out: RM-123-1-1-11-OUT + prefix_list_in: PL-TEST-IN-AF4 + prefix_list_out: PL-TEST-OUT-AF4 local_as: 123 bfd: true - ip_address: fd5a:fe45:8831:06c5::a @@ -189,6 +191,8 @@ tenant_a: send_community: all nodes: [DC1-BL1A, DC1-BL1B] set_ipv6_next_hop: fd5a:fe45:8831:06c5::1 + prefix_list_in: PL-TEST-IN-AF6 + prefix_list_out: PL-TEST-OUT-AF6 - ip_address: fd5a:fe45:8831:06c5::b remote_as: 12345 nodes: [DC1-BL1A, DC1-BL1B] diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index 397f6200629..21d5a30f605 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -629,6 +629,8 @@ | [            activate](## "router_bgp.vrfs.[].address_family_ipv6.neighbors.[].activate") | Boolean | | | | | | [            route_map_in](## "router_bgp.vrfs.[].address_family_ipv6.neighbors.[].route_map_in") | String | | | | Inbound route-map name | | [            route_map_out](## "router_bgp.vrfs.[].address_family_ipv6.neighbors.[].route_map_out") | String | | | | Outbound route-map name | + | [            prefix_list_in](## "router_bgp.vrfs.[].address_family_ipv6.neighbors.[].prefix_list_in") | String | | | | Inbound prefix-list name | + | [            prefix_list_out](## "router_bgp.vrfs.[].address_family_ipv6.neighbors.[].prefix_list_out") | String | | | | Outbound prefix-list name | | [        networks](## "router_bgp.vrfs.[].address_family_ipv6.networks") | List, items: Dictionary | | | | | | [          - prefix](## "router_bgp.vrfs.[].address_family_ipv6.networks.[].prefix") | String | Required, Unique | | | IPv6 prefix "A:B:C:D:E:F:G:H/I" | | [            route_map](## "router_bgp.vrfs.[].address_family_ipv6.networks.[].route_map") | String | | | | | @@ -1756,6 +1758,12 @@ # Outbound route-map name route_map_out: + + # Inbound prefix-list name + prefix_list_in: + + # Outbound prefix-list name + prefix_list_out: networks: # IPv6 prefix "A:B:C:D:E:F:G:H/I" 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 66eb39150eb..9f4f62b3766 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 @@ -18210,6 +18210,16 @@ "type": "string", "description": "Outbound route-map name", "title": "Route Map Out" + }, + "prefix_list_in": { + "type": "string", + "description": "Inbound prefix-list name", + "title": "Prefix List In" + }, + "prefix_list_out": { + "type": "string", + "description": "Outbound prefix-list name", + "title": "Prefix List Out" } }, "additionalProperties": false, 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 f38a29cc739..9423693c5a0 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 @@ -10549,6 +10549,12 @@ keys: route_map_out: type: str description: Outbound route-map name + prefix_list_in: + type: str + description: Inbound prefix-list name + prefix_list_out: + type: str + description: Outbound prefix-list name networks: type: list primary_key: prefix diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml index fce2496a504..d6dec791c65 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml @@ -2204,6 +2204,12 @@ keys: route_map_out: type: str description: Outbound route-map name + prefix_list_in: + type: str + description: Inbound prefix-list name + prefix_list_out: + type: str + description: Outbound prefix-list name networks: type: list primary_key: prefix diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 index ffba8a0dc93..eca4e1bab43 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/router-bgp.j2 @@ -1573,6 +1573,12 @@ router bgp {{ router_bgp.as }} {% if neighbor.route_map_out is arista.avd.defined %} neighbor {{ neighbor.ip_address }} route-map {{ neighbor.route_map_out }} out {% endif %} +{% if neighbor.prefix_list_in is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_in }} in +{% endif %} +{% if neighbor.prefix_list_out is arista.avd.defined %} + neighbor {{ neighbor.ip_address }} prefix-list {{ neighbor.prefix_list_out }} out +{% endif %} {% endfor %} {% for network in vrf.address_family_ipv6.networks | arista.avd.natural_sort('prefix') %} {% set network_cli = "network " ~ network.prefix %} diff --git a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/network-services-vrfs-bgp-settings.md b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/network-services-vrfs-bgp-settings.md index 379e2f52199..d9954a43585 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/network-services-vrfs-bgp-settings.md +++ b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/network-services-vrfs-bgp-settings.md @@ -82,8 +82,8 @@ | [            set_ipv6_next_hop](## ".[].vrfs.[].bgp_peers.[].set_ipv6_next_hop") | String | | | | IPv6_address
Next hop settings can be either ipv4 or ipv6 for one neighbor, this will be applied by a uniquely generated route-map per neighbor.
Next hop takes precedence over route_map_out.
| | [            route_map_out](## ".[].vrfs.[].bgp_peers.[].route_map_out") | String | | | | Route-map name. | | [            route_map_in](## ".[].vrfs.[].bgp_peers.[].route_map_in") | String | | | | Route-map name. | - | [            prefix_list_in](## ".[].vrfs.[].bgp_peers.[].prefix_list_in") | String | | | | Prefix list name. | - | [            prefix_list_out](## ".[].vrfs.[].bgp_peers.[].prefix_list_out") | String | | | | Prefix list name. | + | [            prefix_list_in](## ".[].vrfs.[].bgp_peers.[].prefix_list_in") | String | | | | Inbound prefix list name.
The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. | + | [            prefix_list_out](## ".[].vrfs.[].bgp_peers.[].prefix_list_out") | String | | | | Outbound prefix list name.
The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. | | [            local_as](## ".[].vrfs.[].bgp_peers.[].local_as") | String | | | | Local BGP ASN.
eg. "65001.1200".
| | [            weight](## ".[].vrfs.[].bgp_peers.[].weight") | Integer | | | Min: 0
Max: 65535 | | | [            bfd](## ".[].vrfs.[].bgp_peers.[].bfd") | Boolean | | | | | @@ -329,10 +329,12 @@ # Route-map name. route_map_in: - # Prefix list name. + # Inbound prefix list name. + # The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. prefix_list_in: - # Prefix list name. + # Outbound prefix list name. + # The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. prefix_list_out: # Local BGP ASN. diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py index f086d111a9f..86742661aa0 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py @@ -246,7 +246,14 @@ def _router_bgp_vrfs(self) -> list | None: for bgp_peer in vrf["bgp_peers"]: peer_ip = bgp_peer.pop("ip_address") address_family = f"address_family_ipv{ipaddress.ip_address(peer_ip).version}" - neighbor = {"ip_address": peer_ip, "activate": True} + neighbor = strip_empties_from_dict( + { + "ip_address": peer_ip, + "activate": True, + "prefix_list_in": bgp_peer.pop("prefix_list_in", None), + "prefix_list_out": bgp_peer.pop("prefix_list_out", None), + } + ) bgp_vrf.setdefault(address_family, {}).setdefault("neighbors", []).append(neighbor) if bgp_peer.get("set_ipv4_next_hop") is not None or bgp_peer.get("set_ipv6_next_hop") is not None: 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 e3bee234d65..8d6b6644b67 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 @@ -4836,10 +4836,16 @@ $defs: description: Route-map name. prefix_list_in: type: str - description: Prefix list name. + description: 'Inbound prefix list name. + + The prefix-list will be associated under the IPv4 or IPv6 + address family based on the IP address.' prefix_list_out: type: str - description: Prefix list name. + description: 'Outbound prefix list name. + + The prefix-list will be associated under the IPv4 or IPv6 + address family based on the IP address.' local_as: type: str convert_types: diff --git a/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_network_services.schema.yml b/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_network_services.schema.yml index 335c5074b5f..62a2632db8b 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_network_services.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_designs/schemas/schema_fragments/defs_network_services.schema.yml @@ -856,10 +856,14 @@ $defs: description: Route-map name. prefix_list_in: type: str - description: Prefix list name. + description: |- + Inbound prefix list name. + The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. prefix_list_out: type: str - description: Prefix list name. + description: |- + Outbound prefix list name. + The prefix-list will be associated under the IPv4 or IPv6 address family based on the IP address. local_as: type: str convert_types: From 3bd0795399ad635c6898e1631fb66fc86ade5eb5 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Fri, 17 Nov 2023 13:59:57 +0100 Subject: [PATCH 3/4] Update molecule --- .../documentation/devices/router-bgp-vrf-lite.md | 4 ++++ .../intended/configs/router-bgp-vrf-lite.cfg | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md index b002e0ed075..c36e9e1965b 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/router-bgp-vrf-lite.md @@ -229,6 +229,10 @@ router bgp 65001 address-family ipv4 neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out + ! + address-family ipv6 + neighbor 2001:cafe:192:168::4 prefix-list PL-BGP-V6-RED-IN-C1 in + neighbor 2001:cafe:192:168::4 prefix-list PL-BGP-V6-RED-OUT-C1 out ! vrf YELLOW-C1 rd 1.0.1.1:103 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg index 9c681b1160a..7c5e057ec69 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/router-bgp-vrf-lite.cfg @@ -109,6 +109,10 @@ router bgp 65001 address-family ipv4 neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-IN-C1 in neighbor 10.1.1.0 prefix-list PL-BGP-DEFAULT-RED-OUT-C1 out + ! + address-family ipv6 + neighbor 2001:cafe:192:168::4 prefix-list PL-BGP-V6-RED-IN-C1 in + neighbor 2001:cafe:192:168::4 prefix-list PL-BGP-V6-RED-OUT-C1 out ! vrf YELLOW-C1 rd 1.0.1.1:103 From 32af655d120737409dc9117f2bfb2555fd3d11d2 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Mon, 20 Nov 2023 17:21:29 +0100 Subject: [PATCH 4/4] Address review comments --- .../roles/eos_cli_config_gen/docs/tables/router-bgp.md | 8 ++++---- .../schemas/eos_cli_config_gen.jsonschema.json | 4 ++-- .../schemas/eos_cli_config_gen.schema.yml | 2 ++ .../schemas/schema_fragments/router_bgp.schema.yml | 4 ++-- .../python_modules/network_services/router_bgp.py | 4 ++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md index 21d5a30f605..01954103a9d 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/router-bgp.md @@ -561,8 +561,8 @@ | [          update_source](## "router_bgp.vrfs.[].neighbors.[].update_source") | String | | | | | | [          route_map_in](## "router_bgp.vrfs.[].neighbors.[].route_map_in") | String | | | | Inbound route-map name | | [          route_map_out](## "router_bgp.vrfs.[].neighbors.[].route_map_out") | String | | | | Outbound route-map name | - | [          prefix_list_in](## "router_bgp.vrfs.[].neighbors.[].prefix_list_in") deprecated | String | | | | Inbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead. | - | [          prefix_list_out](## "router_bgp.vrfs.[].neighbors.[].prefix_list_out") deprecated | String | | | | Outbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead. | + | [          prefix_list_in](## "router_bgp.vrfs.[].neighbors.[].prefix_list_in") deprecated | String | | | | Inbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_in instead. | + | [          prefix_list_out](## "router_bgp.vrfs.[].neighbors.[].prefix_list_out") deprecated | String | | | | Outbound prefix-list nameThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_out instead. | | [      neighbor_interfaces](## "router_bgp.vrfs.[].neighbor_interfaces") | List, items: Dictionary | | | | | | [        - name](## "router_bgp.vrfs.[].neighbor_interfaces.[].name") | String | Required, Unique | | | Interface name | | [          remote_as](## "router_bgp.vrfs.[].neighbor_interfaces.[].remote_as") | String | | | | BGP AS <1-4294967295> or AS number in asdot notation "<1-65535>.<0-65535>" | @@ -1652,13 +1652,13 @@ # Inbound prefix-list name # This key is deprecated. # Support will be removed in AVD version 5.0.0. - # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead. + # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_in instead. prefix_list_in: # Outbound prefix-list name # This key is deprecated. # Support will be removed in AVD version 5.0.0. - # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead. + # Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_out instead. prefix_list_out: neighbor_interfaces: 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 9f4f62b3766..2f580b54852 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 @@ -17753,13 +17753,13 @@ }, "prefix_list_in": { "type": "string", - "description": "Inbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in instead.", + "description": "Inbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_in instead.", "deprecated": true, "title": "Prefix List In" }, "prefix_list_out": { "type": "string", - "description": "Outbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out instead.", + "description": "Outbound prefix-list name\nThis key is deprecated. Support will be removed in AVD version 5.0.0. Use router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_out instead.", "deprecated": true, "title": "Prefix List Out" } 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 9423693c5a0..33592f19b5d 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 @@ -10308,6 +10308,7 @@ keys: deprecation: warning: true new_key: router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in + or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_in remove_in_version: 5.0.0 prefix_list_out: type: str @@ -10315,6 +10316,7 @@ keys: deprecation: warning: true new_key: router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out + or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_out remove_in_version: 5.0.0 neighbor_interfaces: type: list diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml index d6dec791c65..2656f2230e9 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/schemas/schema_fragments/router_bgp.schema.yml @@ -1963,14 +1963,14 @@ keys: description: Inbound prefix-list name deprecation: warning: true - new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in" + new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_in or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_in" remove_in_version: 5.0.0 prefix_list_out: type: str description: Outbound prefix-list name deprecation: warning: true - new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out" + new_key: "router_bgp.vrfs[].address_family_ipv4.neighbors[].prefix_list_out or router_bgp.vrfs[].address_family_ipv6.neighbors[].prefix_list_out" remove_in_version: 5.0.0 neighbor_interfaces: type: list diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py index 86742661aa0..1cf6a647b69 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/network_services/router_bgp.py @@ -244,6 +244,10 @@ def _router_bgp_vrfs(self) -> list | None: ) for bgp_peer in vrf["bgp_peers"]: + # Below we pop various keys that are not supported by the eos_cli_config_gen schema. + # The rest of the keys are relayed directly to eos_cli_config_gen. + # 'ip_address' is popped even though it is supported. It will be added again later + # to ensure it comes first in the generated dict. peer_ip = bgp_peer.pop("ip_address") address_family = f"address_family_ipv{ipaddress.ip_address(peer_ip).version}" neighbor = strip_empties_from_dict(