From 1043e6df2d9148f54a8b734b655f446aadefdbc5 Mon Sep 17 00:00:00 2001 From: Vibhu-gslab Date: Thu, 26 Dec 2024 11:42:03 +0530 Subject: [PATCH] Making schema 1:1 and changing code accordingly --- .../inventory/host_vars/DC1-BL1A.yml | 6 +++-- .../eos_designs/docs/tables/event-monitor.md | 6 +++-- ...d-interval-default.md => load-interval.md} | 8 +++++-- .../pyavd/_eos_designs/schema/__init__.py | 24 ++++++++++++------- .../schema/eos_designs.schema.yml | 10 ++++---- .../schema_fragments/event_monitor.schema.yml | 3 ++- .../load_interval_default.schema.yml | 7 +++--- .../structured_config/base/__init__.py | 4 ++-- 8 files changed, 42 insertions(+), 26 deletions(-) rename ansible_collections/arista/avd/roles/eos_designs/docs/tables/{load-interval-default.md => load-interval.md} (56%) diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml index 08747f206d6..a14474e2439 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml @@ -21,10 +21,12 @@ router_id_loopback_description: "MY_ROUTER_ID_LOOPBACK" vtep_vvtep_ip: 192.168.255.255/32 # Testing event_monitor -event_monitor: true +event_monitor: + enabled: true # Testing load_interval_default -load_interval_default: 6 +load_interval: + default: 6 # Testing unsupported_transceiver unsupported_transceiver: diff --git a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/event-monitor.md b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/event-monitor.md index 3bfff0c0ca0..c439c25033d 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/event-monitor.md +++ b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/event-monitor.md @@ -7,10 +7,12 @@ | Variable | Type | Required | Default | Value Restrictions | Description | | -------- | ---- | -------- | ------- | ------------------ | ----------- | - | [event_monitor](## "event_monitor") | Boolean | | | | | + | [event_monitor](## "event_monitor") | Dictionary | | | | | + | [  enabled](## "event_monitor.enabled") | Boolean | | | | | === "YAML" ```yaml - event_monitor: + event_monitor: + enabled: ``` diff --git a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval-default.md b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval.md similarity index 56% rename from ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval-default.md rename to ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval.md index fd769457adb..e92a59a4ab8 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval-default.md +++ b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/load-interval.md @@ -7,10 +7,14 @@ | Variable | Type | Required | Default | Value Restrictions | Description | | -------- | ---- | -------- | ------- | ------------------ | ----------- | - | [load_interval_default](## "load_interval_default") | Integer | | | | | + | [load_interval](## "load_interval") | Dictionary | | | | | + | [  default](## "load_interval.default") | Integer | | | | Default load interval in seconds. | === "YAML" ```yaml - load_interval_default: + load_interval: + + # Default load interval in seconds. + default: ``` diff --git a/python-avd/pyavd/_eos_designs/schema/__init__.py b/python-avd/pyavd/_eos_designs/schema/__init__.py index 2b6ccaaabff..e75d288bc56 100644 --- a/python-avd/pyavd/_eos_designs/schema/__init__.py +++ b/python-avd/pyavd/_eos_designs/schema/__init__.py @@ -3003,6 +3003,9 @@ def __init__( class EventHandlers(EosCliConfigGen.EventHandlers): pass + class EventMonitor(EosCliConfigGen.EventMonitor): + """Subclass of AvdModel.""" + class EvpnHostflapDetection(AvdModel): """Subclass of AvdModel.""" @@ -6837,6 +6840,9 @@ class L3InterfaceProfiles(AvdIndexedList[str, L3InterfaceProfilesItem]): L3InterfaceProfiles._item_type = L3InterfaceProfilesItem + class LoadInterval(EosCliConfigGen.LoadInterval): + """Subclass of AvdModel.""" + class LocalUsers(EosCliConfigGen.LocalUsers): pass @@ -54380,7 +54386,7 @@ def __init__( "eos_designs_custom_templates": {"type": EosDesignsCustomTemplates}, "eos_designs_documentation": {"type": EosDesignsDocumentation}, "event_handlers": {"type": EventHandlers}, - "event_monitor": {"type": bool}, + "event_monitor": {"type": EventMonitor}, "evpn_ebgp_gateway_inter_domain": {"type": bool}, "evpn_ebgp_gateway_multihop": {"type": int, "default": 15}, "evpn_ebgp_multihop": {"type": int, "default": 3}, @@ -54419,7 +54425,7 @@ def __init__( "isis_ti_lfa": {"type": IsisTiLfa}, "l3_edge": {"type": L3Edge}, "l3_interface_profiles": {"type": L3InterfaceProfiles}, - "load_interval_default": {"type": int}, + "load_interval": {"type": LoadInterval}, "local_users": {"type": LocalUsers}, "mac_address_table": {"type": MacAddressTable}, "management_eapi": {"type": ManagementEapi}, @@ -55208,7 +55214,8 @@ def __init__( customize the system behavior, and implement workarounds to problems discovered in the field. """ - event_monitor: bool | None + event_monitor: EventMonitor + """Subclass of AvdModel.""" evpn_ebgp_gateway_inter_domain: bool | None evpn_ebgp_gateway_multihop: int """ @@ -55455,7 +55462,8 @@ def __init__( Subclass of AvdIndexedList with `L3InterfaceProfilesItem` items. Primary key is `profile` (`str`). """ - load_interval_default: int | None + load_interval: LoadInterval + """Subclass of AvdModel.""" local_users: LocalUsers mac_address_table: MacAddressTable """ @@ -56477,7 +56485,7 @@ def __init__( eos_designs_custom_templates: EosDesignsCustomTemplates | UndefinedType = Undefined, eos_designs_documentation: EosDesignsDocumentation | UndefinedType = Undefined, event_handlers: EventHandlers | UndefinedType = Undefined, - event_monitor: bool | None | UndefinedType = Undefined, + event_monitor: EventMonitor | UndefinedType = Undefined, evpn_ebgp_gateway_inter_domain: bool | None | UndefinedType = Undefined, evpn_ebgp_gateway_multihop: int | UndefinedType = Undefined, evpn_ebgp_multihop: int | UndefinedType = Undefined, @@ -56513,7 +56521,7 @@ def __init__( isis_ti_lfa: IsisTiLfa | UndefinedType = Undefined, l3_edge: L3Edge | UndefinedType = Undefined, l3_interface_profiles: L3InterfaceProfiles | UndefinedType = Undefined, - load_interval_default: int | None | UndefinedType = Undefined, + load_interval: LoadInterval | UndefinedType = Undefined, local_users: LocalUsers | UndefinedType = Undefined, mac_address_table: MacAddressTable | UndefinedType = Undefined, management_eapi: ManagementEapi | UndefinedType = Undefined, @@ -57031,7 +57039,7 @@ def __init__( flexible tool that can be used to apply self-healing actions, customize the system behavior, and implement workarounds to problems discovered in the field. - event_monitor: event_monitor + event_monitor: Subclass of AvdModel. evpn_ebgp_gateway_inter_domain: evpn_ebgp_gateway_inter_domain evpn_ebgp_gateway_multihop: Default of 15, considering a large value to avoid BGP reachability issues in very complex DCI @@ -57189,7 +57197,7 @@ def __init__( Subclass of AvdIndexedList with `L3InterfaceProfilesItem` items. Primary key is `profile` (`str`). - load_interval_default: load_interval_default + load_interval: Subclass of AvdModel. local_users: local_users mac_address_table: MAC address-table aging time. diff --git a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml index 31d706daccb..65165160c22 100644 --- a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml +++ b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml @@ -1187,7 +1187,8 @@ keys: table: management-settings type: list event_monitor: - type: bool + type: dict + $ref: eos_cli_config_gen#/keys/event_monitor evpn_ebgp_gateway_inter_domain: documentation_options: table: evpn-settings @@ -2044,10 +2045,9 @@ keys: type: str description: L3 interface profile name. Any variable supported under `l3_interfaces` can be inherited from a profile. - load_interval_default: - type: int - convert_types: - - str + load_interval: + type: dict + $ref: eos_cli_config_gen#/keys/load_interval local_users: documentation_options: table: management-settings diff --git a/python-avd/pyavd/_eos_designs/schema/schema_fragments/event_monitor.schema.yml b/python-avd/pyavd/_eos_designs/schema/schema_fragments/event_monitor.schema.yml index 3a46bf35bdc..52dd251e145 100644 --- a/python-avd/pyavd/_eos_designs/schema/schema_fragments/event_monitor.schema.yml +++ b/python-avd/pyavd/_eos_designs/schema/schema_fragments/event_monitor.schema.yml @@ -7,4 +7,5 @@ type: dict keys: event_monitor: - type: bool + type: dict + $ref: "eos_cli_config_gen#/keys/event_monitor" diff --git a/python-avd/pyavd/_eos_designs/schema/schema_fragments/load_interval_default.schema.yml b/python-avd/pyavd/_eos_designs/schema/schema_fragments/load_interval_default.schema.yml index 4b3758192a7..65b3808a95d 100644 --- a/python-avd/pyavd/_eos_designs/schema/schema_fragments/load_interval_default.schema.yml +++ b/python-avd/pyavd/_eos_designs/schema/schema_fragments/load_interval_default.schema.yml @@ -6,7 +6,6 @@ # Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters. type: dict keys: - load_interval_default: - type: int - convert_types: - - str + load_interval: + type: dict + $ref: "eos_cli_config_gen#/keys/load_interval" diff --git a/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py b/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py index f9ba97e4655..1c432e1e88b 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py +++ b/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py @@ -340,7 +340,7 @@ def transceiver_qsfp_default_mode_4x10(self) -> bool: @cached_property def event_monitor(self) -> dict | None: """event_monitor set based on event_monitor data-model.""" - if get(self._hostvars, "event_monitor") is True: + if get(self._hostvars, "event_monitor.enabled") is True: return {"enabled": True} return None @@ -352,7 +352,7 @@ def event_handlers(self) -> list | None: @cached_property def load_interval(self) -> dict | None: """load_interval set based on load_interval_default variable.""" - if (load_interval_default := get(self._hostvars, "load_interval_default")) is not None: + if (load_interval_default := get(self._hostvars, "load_interval.default")) is not None: return {"default": load_interval_default} return None