Skip to content

Commit

Permalink
updated the code logic plus documentation_options for router id
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh Kumar authored and Mahesh Kumar committed Dec 11, 2024
1 parent 25d6200 commit 4845c38
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 46 deletions.

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.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

16 changes: 8 additions & 8 deletions python-avd/pyavd/_eos_designs/schema/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml

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 @@ -490,7 +490,7 @@ $defs:
type: str
description: |-
Router ID to use for OSPF in this VRF.
This can be an IP address, "main_router_id", "none", "vtep_diagnostic"
This can be an IPv4 address, "main_router_id", "none" or "vtep_diagnostic".
- "main_router_id" will reuse the main OSPF Router ID which is the IP address of Loopback0.
- "none" will not configure a OSPF Router ID for this VRF. EOS will use the main OSPF Router ID.
- "vtep_diagnostic" will use the IP address of the VRF Diagnostic Loopback interface.
Expand Down Expand Up @@ -1068,7 +1068,7 @@ $defs:
type: str
description: |-
Router ID to use for BGP in this VRF.
This can be an IP address, "main_router_id", "none", "vtep_diagnostic"
This can be an IPv4 address, "main_router_id", "none" or "vtep_diagnostic".
- "main_router_id" will reuse the main BGP Router ID which is the IP address of Loopback0.
- "none" will not configure a BGP Router ID for this VRF. EOS will use the main BGP Router ID.
- "vtep_diagnostic" will use the IP address of the VRF Diagnostic Loopback interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
type: dict
keys:
use_router_general_for_router_id:
documentation_options:
table: fabric-settings
type: bool
description: Use `router general` to set router ID for all routing protocols and VRFs.
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def get_vrf_router_id(
Args:
vrf (VrfsItem): The VRF object containing OSPF/BGP and vtep_diagnostic details.
router_id (str): The router ID type specified for the VRF (e.g., "vtep_diagnostic", "main_router_id", "none", or "IPv4 address").
router_id (str): The router ID type specified for the VRF (e.g., "vtep_diagnostic", "main_router_id", "none", or an IPv4 address).
tenant_name (str): The name of the tenant to which the VRF belongs.
Returns:
Expand All @@ -425,28 +425,19 @@ def get_vrf_router_id(
"""
# Handle "vtep_diagnostic" router ID case
if router_id == "vtep_diagnostic":
interface_data = self._get_vtep_diagnostic_loopback_for_vrf(vrf)

# Validate required configuration
if interface_data is None:
if (interface_data := self._get_vtep_diagnostic_loopback_for_vrf(vrf)) is None:
msg = (
f"Invalid configuration on VRF '{vrf.name}' in Tenant '{tenant_name}'. "
"'vtep_diagnostic.loopback' along with either 'vtep_diagnostic.loopback_ip_pools' or 'vtep_diagnostic.loopback_ip_range' must be defined "
"when 'router_id' is set to 'vtep_diagnostic' on the VRF."
)
raise AristaAvdInvalidInputsError(msg)

# Resolve router ID from loopback interface

return get_ip_from_ip_prefix(interface_data["ip_address"])

# Handle "main_router_id" with general router ID enabled/disabled
if router_id == "main_router_id":
if not self.inputs.use_router_general_for_router_id:
return self.shared_utils.router_id
return None

# Handle "none" router ID or custom value
return self.shared_utils.router_id if not self.inputs.use_router_general_for_router_id else None
# Handle "none" router ID
if router_id == "none":
return None

Expand Down

0 comments on commit 4845c38

Please sign in to comment.