diff --git a/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/router_ospf.py b/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/router_ospf.py index ce3d794673e..500c45f5e85 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/router_ospf.py +++ b/python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/router_ospf.py @@ -3,9 +3,11 @@ # 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._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 AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol @@ -17,21 +19,19 @@ class RouterOspfMixin(Protocol): Class should only be used as Mixin to a AvdStructuredConfig class. """ - @cached_property - def router_ospf(self: AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol) -> dict | None: - """Return structured config for router_ospf.""" + @structured_config_contributor + def router_ospf(self: AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol) -> None: + """Set the structured config for router_ospf.""" if not self.shared_utils.underlay_ospf: - return None + return + + no_passive_interfaces = EosCliConfigGen.RouterOspf.ProcessIdsItem.NoPassiveInterfaces() + for p2p_link, p2p_link_data in self._filtered_p2p_links: + if p2p_link.include_in_underlay_protocol: + no_passive_interfaces.append(p2p_link_data["interface"]) - no_passive_interfaces = [p2p_link_data["interface"] for p2p_link, p2p_link_data in self._filtered_p2p_links if p2p_link.include_in_underlay_protocol] if no_passive_interfaces: - return { - "process_ids": [ - { - "id": self.inputs.underlay_ospf_process_id, - "no_passive_interfaces": no_passive_interfaces, - }, - ], - } - - return None + self.structured_config.router_ospf.process_ids.append_new( + id=self.inputs.underlay_ospf_process_id, + no_passive_interfaces=EosCliConfigGen.RouterOspf.ProcessIdsItem.NoPassiveInterfaces(no_passive_interfaces), + )