From cb2286ef781394675d1a6fa2af361488059760f3 Mon Sep 17 00:00:00 2001 From: "Marty Y. Lok" <76118573+mlok-nokia@users.noreply.github.com> Date: Thu, 19 Dec 2024 02:24:29 -0500 Subject: [PATCH] [YangModel][asic_sensors] Add ASIC_SENSORS yang models (#21218) Why I did it Add Yang Models support for ASIC_SENSORS configuration. Work item tracking Microsoft ADO (number only): How I did it Add Yang Models support for the following ASIC_SENSORs configuration { "ASIC_SENSORS": { "ASIC_SENSORS_POLLER_INTERVAL": { "interval": "10" }, "ASIC_SENSORS_POLLER_STATUS": { "admin_status": "enable" } } } How to verify it Image Build should be passed. Signed-off-by: mlok --- src/sonic-yang-models/doc/Configuration.md | 18 +++++ src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 8 ++ .../yang_model_tests/tests/asic-sensors.json | 25 +++++++ .../tests_config/asic-sensors.json | 74 +++++++++++++++++++ .../yang-models/sonic-asic-sensors.yang | 41 ++++++++++ 6 files changed, 167 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/asic-sensors.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/asic-sensors.json create mode 100644 src/sonic-yang-models/yang-models/sonic-asic-sensors.yang diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index d9d761a5546e..4c042b14e232 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -90,6 +90,7 @@ * [SYSTEM_DEFAULTS table](#systemdefaults-table) * [RADIUS](#radius) * [Static DNS](#static-dns) + * [ASIC_SENSORS](#asic_sensors) * [For Developers](#for-developers) * [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template) * [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb) @@ -2914,6 +2915,23 @@ The DPUS table introduces the information on the DPUs (Data Processing Unit) ava } ``` +### ASIC_SENSORS + +The ASIC_SENSORS table introduces the asic sensors polling configuration when they are available on the platform. + +```json +{ + "ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "10" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } + } +} +``` + # For Developers diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 60dba6c410aa..39efe5c842df 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -203,6 +203,7 @@ def run(self): './yang-models/sonic-system-port.yang', './yang-models/sonic-macsec.yang', './yang-models/sonic-bgp-sentinel.yang', + './yang-models/sonic-asic-sensors.yang', './yang-models/sonic-bmp.yang', './yang-models/sonic-xcvrd-log.yang', './yang-models/sonic-grpcclient.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 6f7e90c229ff..67999dd9de4d 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2792,6 +2792,14 @@ "sampling_interval": "5", "retention_period": "15" } + }, + "ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "10" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } } }, "SAMPLE_CONFIG_DB_UNKNOWN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/asic-sensors.json b/src/sonic-yang-models/tests/yang_model_tests/tests/asic-sensors.json new file mode 100644 index 000000000000..227904f40085 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/asic-sensors.json @@ -0,0 +1,25 @@ +{ + "ASIC_SENSORS_TABLE": { + "desc": "Config DB interval parameters for ASIC Sensors polling" + }, + "ASIC_SENSORS_INVALID_POLLER_INTERVAL": { + "desc": "Configure an invalid ASIC Sensors polling interval", + "eStrKey" : "Pattern" + }, + "ASIC_SENSORS_INVALID_POLLER_ADMIN_STATUS": { + "desc": "Configure an invalid ASIC Sensors polling admin status", + "eStrKey" : "InvalidValue" + }, + "ASIC_SENSORS_POLLER_INTERVAL_BAD_LEN_MAX": { + "desc": "Configure an invalid ASIC Sensors polling interval: out of range value", + "eStrKey" : "InvalidValue" + }, + "ASIC_SENSORS_POLLER_INTERVAL_EMPTY_VALUE": { + "desc": "Configure an empty ASIC Sensors polling interval", + "eStrKey" : "InvalidValue" + }, + "ASIC_SENSORS_POLLER_ADMIN_STATUS_EMPTY_VALUE": { + "desc": "Configure an empty ASIC Sensors polling admin status", + "eStrKey" : "InvalidValue" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/asic-sensors.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/asic-sensors.json new file mode 100644 index 000000000000..e9985c69ccc0 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/asic-sensors.json @@ -0,0 +1,74 @@ +{ + "ASIC_SENSORS_TABLE": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "10" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } + } + } + }, + "ASIC_SENSORS_INVALID_POLLER_INTERVAL": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "0" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } + } + } + }, + "ASIC_SENSORS_INVALID_POLLER_ADMIN_STATUS": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "10" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "testing" + } + } + } + }, + "ASIC_SENSORS_POLLER_INTERVAL_BAD_LEN_MAX": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "1010101010101010101010" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } + } + } + }, + "ASIC_SENSORS_POLLER_INTERVAL_EMPTY_VALUE": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "enable" + } + } + } + }, + "ASIC_SENSORS_POLLER_ADMIN_STATUS_EMPTY_VALUE": { + "sonic-asic-sensors:sonic-asic-sensors": { + "sonic-asic-sensors:ASIC_SENSORS": { + "ASIC_SENSORS_POLLER_INTERVAL": { + "interval": "10" + }, + "ASIC_SENSORS_POLLER_STATUS": { + "admin_status": "" + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-asic-sensors.yang b/src/sonic-yang-models/yang-models/sonic-asic-sensors.yang new file mode 100644 index 000000000000..afc25bf4becd --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-asic-sensors.yang @@ -0,0 +1,41 @@ +module sonic-asic-sensors { + yang-version 1.1; + namespace "http://github.com/sonic-net/sonic-asic-sensors"; + prefix asic-sensors; + + import sonic-types { + prefix stypes; + } + + description "ASIC SENSORs config yang Module for SONiC OS"; + + revision 2024-11-19 { + description "First Revision"; + } + + container sonic-asic-sensors { + container ASIC_SENSORS { + description "ASIC_SENSORS part of config_db.json"; + + container ASIC_SENSORS_POLLER_INTERVAL { + leaf interval { + description "ASIC SENSORS polling interval"; + type uint32 { + range "1..999"; + } + units seconds; + default "10 "; + } + } /* ASIC_SENSORS_POLLER_INTERVAL */ + + container ASIC_SENSORS_POLLER_STATUS { + leaf admin_status { + description "ASIC SENSORS polling administrative status"; + type stypes:mode-status; + default "enable"; + } /* admin_status */ + } /* ASIC_SENSORS_POLLER_STATUS */ + + } /* end of ASIC_SENSORS */ + } /* end of container sonic-asic-sensors */ +} /* end of module sonic-asic-sensors */