Skip to content

Commit

Permalink
Merge branch 'devel' into refactor/eos_designs/network-services-route…
Browse files Browse the repository at this point in the history
…r-bgp-output-classes
  • Loading branch information
gmuloc authored Jan 31, 2025
2 parents 6b36eb0 + 074584e commit fb6525a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ zscaler_endpoints:
ip_address: 10.37.121.1 # Not the correct address

expected_error_message: >-
Found duplicate objects with conflicting data while generating configuration for Tunnel interface for Internet Exit policy.
{'name': 'Tunnel100', 'description': 'Internet Exit ZSCALER-EXIT-POLICY-2 PRI',
'ipsec_profile': 'IE-ZSCALER-EXIT-POLICY-2-PROFILE', 'source_interface': 'Ethernet2'}
Found duplicate objects with conflicting data while generating configuration for TunnelInterfaces.
{'name': 'Tunnel100', 'description': 'Internet Exit ZSCALER-EXIT-POLICY-2 PRI', 'mtu': 1394,
'ip_address': 'unnumbered Loopback0', 'tunnel_mode': 'ipsec', 'source_interface': 'Ethernet2',
'destination': '10.37.121.1', 'ipsec_profile': 'IE-ZSCALER-EXIT-POLICY-2-PROFILE',
'nat_profile': 'NAT-IE-ZSCALER'}
conflicts with
{'name': 'Tunnel100', 'description': 'Internet Exit ZSCALER-EXIT-POLICY-1 PRI',
'ipsec_profile': 'IE-ZSCALER-EXIT-POLICY-1-PROFILE', 'source_interface': 'Ethernet1'}.
{'name': 'Tunnel100', 'description': 'Internet Exit ZSCALER-EXIT-POLICY-1 PRI', 'mtu': 1394,
'ip_address': 'unnumbered Loopback0', 'tunnel_mode': 'ipsec', 'source_interface': 'Ethernet1',
'destination': '10.37.121.1', 'ipsec_profile': 'IE-ZSCALER-EXIT-POLICY-1-PROFILE',
'nat_profile': 'NAT-IE-ZSCALER'}.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# that can be found in the LICENSE file.
from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING, Protocol

from pyavd._utils import append_if_not_duplicate
from pyavd._eos_cli_config_gen.schema import EosCliConfigGen
from pyavd._eos_designs.structured_config.structured_config_generator import structured_config_contributor

if TYPE_CHECKING:
from . import AvdStructuredConfigNetworkServicesProtocol
Expand All @@ -19,44 +19,31 @@ class TunnelInterfacesMixin(Protocol):
Class should only be used as Mixin to a AvdStructuredConfig class.
"""

@cached_property
def tunnel_interfaces(self: AvdStructuredConfigNetworkServicesProtocol) -> list | None:
@structured_config_contributor
def tunnel_interfaces(self: AvdStructuredConfigNetworkServicesProtocol) -> None:
"""
Return structured config for tunnel_interfaces.
Set structured config for tunnel_interfaces.
Only used for CV Pathfinder edge routers today
"""
if not self._filtered_internet_exit_policies_and_connections:
return None

tunnel_interfaces = []
return

for internet_exit_policy, connections in self._filtered_internet_exit_policies_and_connections:
for connection in connections:
if connection["type"] == "tunnel":
tunnel_interface = {
"name": f"Tunnel{connection['tunnel_id']}",
"description": connection["description"],
"mtu": 1394, # TODO: do not hardcode
"ip_address": connection["tunnel_ip_address"],
"tunnel_mode": "ipsec", # TODO: do not hardcode
"source_interface": connection["source_interface"],
"destination": connection["tunnel_destination_ip"],
"ipsec_profile": connection["ipsec_profile"],
}

if internet_exit_policy.type == "zscaler":
tunnel_interface["nat_profile"] = self.get_internet_exit_nat_profile_name(internet_exit_policy.type)

append_if_not_duplicate(
list_of_dicts=tunnel_interfaces,
primary_key="name",
new_dict=tunnel_interface,
context="Tunnel interface for Internet Exit policy",
context_keys=["name"],
tunnel_interface = EosCliConfigGen.TunnelInterfacesItem(
name=f"Tunnel{connection['tunnel_id']}",
description=connection["description"],
mtu=1394, # TODO: do not hardcode
ip_address=connection["tunnel_ip_address"],
tunnel_mode="ipsec", # TODO: do not hardcode
source_interface=connection["source_interface"],
destination=connection["tunnel_destination_ip"],
ipsec_profile=connection["ipsec_profile"],
)

if tunnel_interfaces:
return tunnel_interfaces
if internet_exit_policy.type == "zscaler":
tunnel_interface.nat_profile = self.get_internet_exit_nat_profile_name(internet_exit_policy.type)

return None
self.structured_config.tunnel_interfaces.append(tunnel_interface)

0 comments on commit fb6525a

Please sign in to comment.