diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index b5890681ce41..9a8f2a9fe285 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -25,6 +25,7 @@ Table of Contents * [Device neighbor metada](#device-neighbor-metada) * [DSCP_TO_TC_MAP](#dscp_to_tc_map) * [FLEX_COUNTER_TABLE](#flex_counter_table) + * [KDUMP](#kdump) * [L2 Neighbors](#l2-neighbors) * [Loopback Interface](#loopback-interface) * [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN) @@ -861,6 +862,20 @@ instance is supported in SONiC. ``` +### KDUMP + +``` +{ + "KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "3", + "memory": "0M-2G:256M,2G-4G:256M,4G-8G:384M,8G-:448M" + } + } +} + +``` ### L2 Neighbors diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 2b55946cc144..1298b768bafb 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -105,6 +105,7 @@ def run(self): './yang-models/sonic-flex_counter.yang', './yang-models/sonic-feature.yang', './yang-models/sonic-interface.yang', + './yang-models/sonic-kdump.yang', './yang-models/sonic-loopback-interface.yang', './yang-models/sonic-mgmt_interface.yang', './yang-models/sonic-mgmt_port.yang', @@ -164,6 +165,7 @@ def run(self): './cvlyang-models/sonic-flex_counter.yang', './cvlyang-models/sonic-feature.yang', './cvlyang-models/sonic-interface.yang', + './cvlyang-models/sonic-kdump.yang', './cvlyang-models/sonic-loopback-interface.yang', './cvlyang-models/sonic-mgmt_interface.yang', './cvlyang-models/sonic-mgmt_port.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 a214560de759..5af414359b29 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1792,7 +1792,15 @@ "rrclient": "0", "admin_status": "up" } - } + }, + + "KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "3", + "memory": "0M-2G:256M,2G-4G:256M,4G-8G:384M,8G-:448M" + } + } }, "SAMPLE_CONFIG_DB_UNKNOWN": { "UNKNOWN_TABLE": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/kdump.json b/src/sonic-yang-models/tests/yang_model_tests/tests/kdump.json new file mode 100644 index 000000000000..29f026133527 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/kdump.json @@ -0,0 +1,19 @@ +{ + "KDUMP_WITH_VALID_VALUES": { + "desc": "Configuring the kdump with valid values." + }, + "KDUMP_WITH_VALID_VALUES_2": { + "desc": "Configuring the kdump with valid values." + }, + "KDUMP_WITH_VALID_VALUES_3": { + "desc": "Configuring the kdump with valid values." + }, + "KDUMP_WITH_INVALID_NUM_DUMPS": { + "desc": "Configuring kdump config with a invalid number of allowed kdumps.", + "eStr": ["pattern", "does not satisfy"] + }, + "KDUMP_WITH_INVALID_MEMORY": { + "desc": "Configuring kdump config with invalid memory config.", + "eStr": ["pattern", "does not satisfy"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/kdump.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/kdump.json new file mode 100644 index 000000000000..fe31148f50ae --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/kdump.json @@ -0,0 +1,57 @@ +{ + "KDUMP_WITH_VALID_VALUES": { + "sonic-kdump:sonic-kdump": { + "sonic-kdump:KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "3", + "memory": "0M-2G:256M,2G-4G:256M,4G-8G:384M,8G-:448M" + } + } + } + }, + "KDUMP_WITH_VALID_VALUES_2": { + "sonic-kdump:sonic-kdump": { + "sonic-kdump:KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "9", + "memory": "512M" + } + } + } + }, + "KDUMP_WITH_VALID_VALUES_3": { + "sonic-kdump:sonic-kdump": { + "sonic-kdump:KDUMP": { + "config": { + "enabled": "false", + "num_dumps": "1", + "memory": "512M" + } + } + } + }, + "KDUMP_WITH_INVALID_NUM_DUMPS": { + "sonic-kdump:sonic-kdump": { + "sonic-kdump:KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "100", + "memory": "0M-2G:256M,2G-4G:256M,4G-8G:384M,8G-:448M" + } + } + } + }, + "KDUMP_WITH_INVALID_MEMORY": { + "sonic-kdump:sonic-kdump": { + "sonic-kdump:KDUMP": { + "config": { + "enabled": "true", + "num_dumps": "3", + "memory": "666" + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-kdump.yang b/src/sonic-yang-models/yang-models/sonic-kdump.yang new file mode 100644 index 000000000000..c7640ee0c754 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-kdump.yang @@ -0,0 +1,60 @@ +module sonic-kdump { + namespace "http://github.com/Azure/sonic-kdump"; + prefix kdump; + yang-version 1.1; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "This module contains a collection of YANG definitions for the + Linux Kernel crash dumping (Kdump) mechanism. The Kdump feature + is used to detect and record Linux kernel crash events."; + + revision 2022-05-09 { + description + "Initial revision."; + } + + container sonic-kdump { + container KDUMP { + description + "Kdump configuration parameters"; + container config { + description "Top level grouping for attributes for Kdump."; + leaf enabled { + type boolean; + description + "Enable or Disable the Kdump mechanism"; + } + + leaf memory { + type string { + pattern "(((([0-9]+[MG])?(-([0-9]+[MG])?):)?[0-9]+[MG],?)+)"; + } + description + "Memory reserved for loading the crash handler kernel. The amount + of reserved memory can be variable, depending on the total amount + of installed memory. The syntax for variable memory reservation is + :,:. For example, 512M-2G:64M,2G-:128M, + where a memory of 64MB is reserved for the crash kernel for systems + with installed memory between 512MB and 2GB, 128MB is reserved for + systems that have more than 2GB installed memory. An absolute memory + value can also be specified in the format M or G. + For example, 512M."; + } + + leaf num_dumps { + type uint8 { + range "1 .. 9"; + } + description + "Maximum number of Kernel Core files Stored"; + } + } + } + } +}