Skip to content

Commit

Permalink
Fix(eos_designs): Use WAN VNI for cv-pathfinder metadata (#3728)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausHolbechArista authored Mar 11, 2024
1 parent 249b232 commit 0928fde
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ metadata:
- name: MPLS
preference: alternate
- name: PROD
vni: 142
vni: 42
avts:
- constraints:
jitter: 42
Expand Down Expand Up @@ -658,7 +658,7 @@ metadata:
- name: MPLS
preference: alternate
- name: IT
vni: 1000
vni: 100
avts:
- id: 3
name: DEFAULT-AVT-POLICY-VIDEO
Expand Down Expand Up @@ -704,7 +704,7 @@ metadata:
- name: MPLS
preference: alternate
- name: ATTRACTED-VRF-FROM-UPLINK
vni: 666
vni: 166
avts:
- id: 1
name: DEFAULT-POLICY-DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ metadata:
- name: MPLS
preference: alternate
- name: PROD
vni: 142
vni: 42
avts:
- constraints:
jitter: 42
Expand Down Expand Up @@ -645,7 +645,7 @@ metadata:
- name: MPLS
preference: alternate
- name: IT
vni: 1000
vni: 100
avts:
- id: 3
name: DEFAULT-AVT-POLICY-VIDEO
Expand Down Expand Up @@ -691,7 +691,7 @@ metadata:
- name: MPLS
preference: alternate
- name: ATTRACTED-VRF-FROM-UPLINK
vni: 666
vni: 166
avts:
- id: 1
name: DEFAULT-POLICY-DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ metadata:
- name: MPLS
preference: alternate
- name: PROD
vni: 142
vni: 42
avts:
- constraints:
jitter: 42
Expand Down Expand Up @@ -677,7 +677,7 @@ metadata:
- name: MPLS
preference: alternate
- name: IT
vni: 1000
vni: 100
avts:
- id: 3
name: DEFAULT-AVT-POLICY-VIDEO
Expand Down Expand Up @@ -723,7 +723,7 @@ metadata:
- name: MPLS
preference: alternate
- name: ATTRACTED-VRF-FROM-UPLINK
vni: 666
vni: 166
avts:
- id: 1
name: DEFAULT-POLICY-DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from functools import cached_property
from typing import TYPE_CHECKING

from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts
from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdError
from ansible_collections.arista.avd.plugins.plugin_utils.utils import get, get_item

Expand Down Expand Up @@ -184,27 +183,18 @@ def _metadata_vrfs(self: AvdStructuredConfigMetadata) -> list:
]

@cached_property
def _all_vrfs_from_all_tenants(self: AvdStructuredConfigMetadata) -> list[dict]:
def _wan_virtual_topologies_vrfs(self: AvdStructuredConfigMetadata) -> list[dict]:
"""
Unfiltered list of VRFs found under tenants.
Unfiltered list of VRFs found under wan_virtual_topologies.
Used to find VNI for each VRF used in cv_pathfinder.
We cannot use filtered_tenants since pathfinders do not necessarily have all VRFs defined in the policies.
Potential issue with this is if some VRFs are defined multiple times with different information.
"""
all_vrfs = [
vrf
for network_services_key in self.shared_utils.network_services_keys
for tenant in convert_dicts(get(self._hostvars, network_services_key["name"]), "name")
for vrf in tenant["vrfs"]
]
# Add the default WAN VRF at the end. Will only be reached if default VRF was not defined in inputs
all_vrfs.append({"name": "default", "vrf_id": 1})
return all_vrfs
return get(self._hostvars, "wan_virtual_topologies.vrfs", default=[])

def _get_vni_for_vrf_name(self: AvdStructuredConfigMetadata, vrf_name: str):
if (vrf := get_item(self._all_vrfs_from_all_tenants, "name", vrf_name)) is None:
raise AristaAvdError(f"Unable to find VNI for VRF {vrf_name} during generation of cv_pathfinder metadata.")
if (vrf := get_item(self._wan_virtual_topologies_vrfs, "name", vrf_name)) is None or (wan_vni := vrf.get("wan_vni")) is None:
if vrf_name == "default":
return 1

raise AristaAvdError(f"Unable to find the WAN VNI for VRF {vrf_name} during generation of cv_pathfinder metadata.")

return self.shared_utils.get_vrf_vni(vrf)
return wan_vni

0 comments on commit 0928fde

Please sign in to comment.