Skip to content

Commit

Permalink
Feat(eos_designs): Allow reuse of cross-device BGP peer ip (aristanet…
Browse files Browse the repository at this point in the history
  • Loading branch information
laxmikantchintakindi authored Jun 7, 2024
1 parent 76713ba commit 6d09d8b
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
type: l3leaf
l3leaf:
defaults:
loopback_ipv4_pool: 10.42.0.0/24
vtep_loopback_ipv4_pool: 10.43.0.0/24
bgp_as: 42
nodes:
- name: duplicate-peer-ip-address-network-services
id: 42

tenants:
- name: Tenant_C
mac_vrf_vni_base: 30000
evpn_l2_multi_domain: false
bgp_peer_groups:
- name: Tenant_C_BGP_PEER_GROUP
remote_as: "666"
- name: Tenant_C_BGP_PEER_GROUP2
remote_as: "667"
vrfs:
- name: Tenant_C_WAN_Zone
vrf_vni: 31
svis:
- id: 350
name: Tenant_C_WAN_Zone_1
tags: ['wan']
enabled: True
bgp_peers:
- ip_address: 2.2.2.2
peer_group: Tenant_C_BGP_PEER_GROUP
nodes: [ duplicate-peer-ip-address-network-services ]
- ip_address: 2.2.2.2
peer_group: Tenant_C_BGP_PEER_GROUP2
nodes: [ duplicate-peer-ip-address-network-services ]

expected_error_message: |-
Found duplicate objects with conflicting data while generating configuration for BGP peer defined under VRFs. {'ip_address': '2.2.2.2', 'peer_group': 'Tenant_C_BGP_PEER_GROUP2'} conflicts with {'ip_address': '2.2.2.2', 'peer_group': 'Tenant_C_BGP_PEER_GROUP'}.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ all:
duplicate-vrfs-tenant-igmp-snooping-conflict:
duplicate-interface-l3-edge:
duplicate-l3-interfaces-network-services:
duplicate-peer-ip-address-network-services:
duplicate-interfaces-point-to-point-services-1:
duplicate-interfaces-point-to-point-services-2:
duplicate-interfaces-point-to-point-services-3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,15 @@ router bgp 65107
neighbor 1.1.1.1 peer group Tenant_C_WAN_Zone_BGP_PEER_GROUP
neighbor 1.1.1.1 description test_description
neighbor 1.1.1.1 route-map RM-Tenant_C_WAN_Zone-1.1.1.1-SET-NEXT-HOP-OUT out
neighbor 2.2.2.3 peer group Tenant_C_WAN_Zone_BGP_PEER_GROUP
neighbor 2.2.2.3 description test_duplicate_peer_ip_address
neighbor BEBA::C0CA:C07A peer group Tenant_C_WAN_Zone_BGP_PEER_GROUP
neighbor BEBA::C0CA:C07A description test_ipv6
redistribute connected
!
address-family ipv4
neighbor 1.1.1.1 activate
neighbor 2.2.2.3 activate
!
address-family ipv6
neighbor BEBA::C0CA:C07A activate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,16 @@ router_bgp:
neighbors:
- ip_address: 1.1.1.1
activate: true
- ip_address: 2.2.2.3
activate: true
neighbors:
- ip_address: 1.1.1.1
peer_group: Tenant_C_WAN_Zone_BGP_PEER_GROUP
description: test_description
route_map_out: RM-Tenant_C_WAN_Zone-1.1.1.1-SET-NEXT-HOP-OUT
- ip_address: 2.2.2.3
peer_group: Tenant_C_WAN_Zone_BGP_PEER_GROUP
description: test_duplicate_peer_ip_address
- ip_address: BEBA::C0CA:C07A
peer_group: Tenant_C_WAN_Zone_BGP_PEER_GROUP
description: test_ipv6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ tenant_c:
peer_group: Tenant_C_BGP_PEER_GROUP2
nodes: [DC1-BL2A]
description: test_bgp_peer_group_without_nodes_2nd_time
- ip_address: 2.2.2.3
peer_group: Tenant_C_WAN_Zone_BGP_PEER_GROUP
nodes: [ DC1-BL2B ]
description: test_duplicate_peer_ip_address
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;vrfs</samp>](## "<network_services_keys.name>.[].vrfs") | List, items: Dictionary | | | | VRFs will only be configured on a node if any of the underlying objects like `svis` or `l3_interfaces` apply to the node.<br><br>It is recommended to only define a VRF in one Tenant. If the same VRF name is used across multiple tenants and those tenants<br>are accepted by `filter.tenants` on the node, any object set under the duplicate VRFs must either be unique or be an exact match.<br><br>VRF "default" is partially supported under network-services. Currently the supported options for "default" vrf are route-target,<br>route-distinguisher settings, structured_config, raw_eos_cli in bgp and SVIs are the only supported interface type.<br>Vlan-aware-bundles are supported as well inside default vrf. OSPF is not supported currently.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name</samp>](## "<network_services_keys.name>.[].vrfs.[].name") | String | Required, Unique | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bgp_peers</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers") | List, items: Dictionary | | | | List of BGP peer definitions.<br>This will configure BGP neighbors inside the tenant VRF for peering with external devices.<br>The configured peer will automatically be activated for ipv4 or ipv6 address family based on the ip address.<br>Note, only ipv4 and ipv6 address families are currently supported in eos_designs.<br>For other address families, use custom_structured configuration with eos_cli_config_gen.<br> |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;ip_address</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers.[].ip_address") | String | Required, Unique | | | IPv4_address or IPv6_address. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;ip_address</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers.[].ip_address") | String | Required | | | IPv4_address or IPv6_address. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;peer_group</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers.[].peer_group") | String | | | | Peer group name. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remote_as</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers.[].remote_as") | String | | | | BGP AS <1-4294967295> or AS number in asdot notation "<1-65535>.<0-65535>".<br>For asdot notation in YAML inputs, the value must be put in quotes, to prevent it from being interpreted as a float number. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description</samp>](## "<network_services_keys.name>.[].vrfs.[].bgp_peers.[].description") | String | | | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ def _router_bgp_vrfs(self) -> list | None:
"prefix_list_out": bgp_peer.pop("prefix_list_out", None),
}
)
bgp_vrf.setdefault(address_family, {}).setdefault("neighbors", []).append(neighbor)

append_if_not_duplicate(
list_of_dicts=bgp_vrf.setdefault(address_family, {}).setdefault("neighbors", []),
primary_key="ip_address",
new_dict=neighbor,
context="BGP peer defined under VRFs",
context_keys=["ip_address"],
)

if bgp_peer.get("set_ipv4_next_hop") is not None or bgp_peer.get("set_ipv6_next_hop") is not None:
route_map = f"RM-{vrf_name}-{peer_ip}-SET-NEXT-HOP-OUT"
Expand All @@ -208,7 +215,14 @@ def _router_bgp_vrfs(self) -> list | None:
bgp_peer.pop("set_ipv6_next_hop", None)

bgp_peer.pop("nodes", None)
bgp_vrf.setdefault("neighbors", []).append({"ip_address": peer_ip, **bgp_peer})

append_if_not_duplicate(
list_of_dicts=bgp_vrf.setdefault("neighbors", []),
primary_key="ip_address",
new_dict={"ip_address": peer_ip, **bgp_peer},
context="BGP peer defined under VRFs",
context_keys=["ip_address"],
)

if (
get(vrf, "ospf.enabled") is True
Expand Down

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 @@ -894,6 +894,7 @@ $defs:
table: network-services-vrfs-bgp-settings
type: list
primary_key: ip_address
allow_duplicate_primary_key: True
convert_types:
- dict
description: |
Expand Down

0 comments on commit 6d09d8b

Please sign in to comment.