Skip to content

Commit

Permalink
Refactor(eos_designs): Enforce cross-region site name uniqueness at s…
Browse files Browse the repository at this point in the history
…chema level
  • Loading branch information
gmuloc authored and carlbuchmann committed Jun 19, 2024
1 parent a1f30e4 commit 7de4031
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ keys:
primary_key: name
unique_keys:
- id
- sites.name
items:
type: dict
$ref: eos_cli_config_gen#/keys/router_adaptive_virtual_topology/keys/region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keys:
primary_key: name
unique_keys:
- id
- sites.name
items:
type: dict
$ref: "eos_cli_config_gen#/keys/router_adaptive_virtual_topology/keys/region"
Expand Down
13 changes: 0 additions & 13 deletions python-avd/pyavd/_eos_designs/shared_utils/wan.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ def wan_region(self: SharedUtils) -> dict | None:
"""
WAN region for CV Pathfinder
Also checking if site names are unique across all regions.
The region is required for edges, but optional for pathfinders
"""
node_defined_region = get(
Expand All @@ -286,17 +284,6 @@ def wan_region(self: SharedUtils) -> dict | None:
self.hostvars, "cv_pathfinder_regions", required=True, org_key="'cv_pathfinder_regions' key must be set when 'wan_mode' is 'cv-pathfinder'."
)

# Verify that site names are unique across all regions.
site_names = [site["name"] for region in regions for site in region["sites"]]
if len(site_names) != len(set(site_names)):
# We have some site names that are not unique
# Now find them (slow so no need to do if we don't have duplicates)
duplicate_site_names = [site_name for site_name in site_names if site_names.count(site_name) > 1]
raise AristaAvdError(
"WAN Site names must be unique across all regions. "
f"Found the following duplicate site name(s) under 'cv_pathfinder_regions.[].sites. {duplicate_site_names}"
)

return get_item(
regions,
"name",
Expand Down

0 comments on commit 7de4031

Please sign in to comment.