Skip to content

Commit b9f146d

Browse files
Refactor(eos_designs): structured_config for core_interfaces_and_l3_edge/router_ospf.py (#4977)
1 parent 217695b commit b9f146d

File tree

1 file changed

+16
-16
lines changed
  • python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge

1 file changed

+16
-16
lines changed

Diff for: python-avd/pyavd/_eos_designs/structured_config/core_interfaces_and_l3_edge/router_ospf.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# that can be found in the LICENSE file.
44
from __future__ import annotations
55

6-
from functools import cached_property
76
from typing import TYPE_CHECKING, Protocol
87

8+
from pyavd._eos_cli_config_gen.schema import EosCliConfigGen
9+
from pyavd._eos_designs.structured_config.structured_config_generator import structured_config_contributor
10+
911
if TYPE_CHECKING:
1012
from . import AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol
1113

@@ -17,21 +19,19 @@ class RouterOspfMixin(Protocol):
1719
Class should only be used as Mixin to a AvdStructuredConfig class.
1820
"""
1921

20-
@cached_property
21-
def router_ospf(self: AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol) -> dict | None:
22-
"""Return structured config for router_ospf."""
22+
@structured_config_contributor
23+
def router_ospf(self: AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol) -> None:
24+
"""Set the structured config for router_ospf."""
2325
if not self.shared_utils.underlay_ospf:
24-
return None
26+
return
27+
28+
no_passive_interfaces = EosCliConfigGen.RouterOspf.ProcessIdsItem.NoPassiveInterfaces()
29+
for p2p_link, p2p_link_data in self._filtered_p2p_links:
30+
if p2p_link.include_in_underlay_protocol:
31+
no_passive_interfaces.append(p2p_link_data["interface"])
2532

26-
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]
2733
if no_passive_interfaces:
28-
return {
29-
"process_ids": [
30-
{
31-
"id": self.inputs.underlay_ospf_process_id,
32-
"no_passive_interfaces": no_passive_interfaces,
33-
},
34-
],
35-
}
36-
37-
return None
34+
self.structured_config.router_ospf.process_ids.append_new(
35+
id=self.inputs.underlay_ospf_process_id,
36+
no_passive_interfaces=EosCliConfigGen.RouterOspf.ProcessIdsItem.NoPassiveInterfaces(no_passive_interfaces),
37+
)

0 commit comments

Comments
 (0)