3
3
# that can be found in the LICENSE file.
4
4
from __future__ import annotations
5
5
6
- from functools import cached_property
7
6
from typing import TYPE_CHECKING , Protocol
8
7
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
+
9
11
if TYPE_CHECKING :
10
12
from . import AvdStructuredConfigCoreInterfacesAndL3EdgeProtocol
11
13
@@ -17,21 +19,19 @@ class RouterOspfMixin(Protocol):
17
19
Class should only be used as Mixin to a AvdStructuredConfig class.
18
20
"""
19
21
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."""
23
25
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" ])
25
32
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 ]
27
33
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