From 70af94cfb49b27d1e73a2e4982305710246d99a4 Mon Sep 17 00:00:00 2001 From: Vibhu-gslab <109593615+Vibhu-gslab@users.noreply.github.com> Date: Wed, 5 Feb 2025 20:08:19 +0530 Subject: [PATCH] Refactor(eos_designs): structured_config for agents (#4975) Co-authored-by: laxmikantchintakindi <159624484+laxmikantchintakindi@users.noreply.github.com> Co-authored-by: Shivani-gslab <145646625+Shivani-gslab@users.noreply.github.com> Co-authored-by: Guillaume Mulocher --- .../structured_config/underlay/agents.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python-avd/pyavd/_eos_designs/structured_config/underlay/agents.py b/python-avd/pyavd/_eos_designs/structured_config/underlay/agents.py index 95e80ebbf70..f63ddd50b09 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/underlay/agents.py +++ b/python-avd/pyavd/_eos_designs/structured_config/underlay/agents.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 AvdStructuredConfigUnderlayProtocol @@ -17,12 +19,12 @@ class AgentsMixin(Protocol): Class should only be used as Mixin to a AvdStructuredConfig class. """ - @cached_property - def agents(self: AvdStructuredConfigUnderlayProtocol) -> list | None: - """Return structured config for agents.""" + @structured_config_contributor + def agents(self: AvdStructuredConfigUnderlayProtocol) -> None: + """Set the structured config for agents.""" if not self.shared_utils.is_wan_router: - return None + return - return [ - {"name": "KernelFib", "environment_variables": [{"name": "KERNELFIB_PROGRAM_ALL_ECMP", "value": "1"}]}, - ] + agent = EosCliConfigGen.AgentsItem(name="KernelFib") + agent.environment_variables.append_new(name="KERNELFIB_PROGRAM_ALL_ECMP", value="1") + self.structured_config.agents.append(agent)