diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index d0f4b3cb6e67..ab51762e5d7e 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -25,7 +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) + * [KDUMP](#kdump) * [L2 Neighbors](#l2-neighbors) * [Loopback Interface](#loopback-interface) * [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN) @@ -51,7 +51,8 @@ Table of Contents * [VLAN_MEMBER](#vlan_member) * [Virtual router](#virtual-router) * [WRED_PROFILE](#wred_profile) - * [PASSWORD_HARDENING](#password_hardening) + * [PASSWORD_HARDENING](#password_hardening) + * [SYSTEM_DEFAULTS table](#systemdefaults-table) * [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) @@ -1617,6 +1618,32 @@ The method could be: } ``` +### SYSTEM_DEFAULTS table +To have a better management of the features in SONiC, a new table `SYSTEM_DEFAULTS` is introduced. + +``` +"SYSTEM_DEFAULTS": { + "tunnel_qos_remap": { + "status": "enabled" + } + "default_bgp_status": { + "status": "down" + } + "synchronous_mode": { + "status": "enable" + } + "dhcp_server": { + "status": "enable" + } + } +``` +The default value of flags in `SYSTEM_DEFAULTS` table can be set in `init_cfg.json` and loaded into db at system startup. These flags are usually set at image being build, and are unlikely to change at runtime. + +If the values in `config_db.json` is changed by user, it will not be rewritten back by `init_cfg.json` as `config_db.json` is loaded after `init_cfg.json` in [docker_image_ctl.j2](https://github.com/Azure/sonic-buildimage/blob/master/files/build_templates/docker_image_ctl.j2) + +For the flags that can be changed by reconfiguration, we can update entries in `minigraph.xml`, and parse the new values in to config_db with minigraph parser at reloading minigraph. If there are duplicated entries in `init_cfg.json` and `minigraph.xml`, the values in `minigraph.xml` will overwritten the values defined in `init_cfg.json`. +#### 5.2.3 Update value directly in db memory + For Developers ============== diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 4d61be960c3b..1c2bfaf2755a 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-extension.yang', './yang-models/sonic-flex_counter.yang', './yang-models/sonic-feature.yang', + './yang-models/sonic-system-defaults.yang', './yang-models/sonic-interface.yang', './yang-models/sonic-kdump.yang', './yang-models/sonic-loopback-interface.yang', @@ -168,6 +169,7 @@ def run(self): './cvlyang-models/sonic-extension.yang', './cvlyang-models/sonic-flex_counter.yang', './cvlyang-models/sonic-feature.yang', + './cvlyang-models/sonic-system-defaults.yang', './cvlyang-models/sonic-interface.yang', './cvlyang-models/sonic-kdump.yang', './cvlyang-models/sonic-loopback-interface.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 d8f90284091a..1967e1629a8e 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1890,8 +1890,12 @@ "LAG" ] } + }, + "SYSTEM_DEFAULTS": { + "tunnel_qos_remap": { + "status": "enabled" + } }, - "LOSSLESS_TRAFFIC_PATTERN": { "AZURE": { "mtu": "1024", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/system_defaults.json b/src/sonic-yang-models/tests/yang_model_tests/tests/system_defaults.json new file mode 100644 index 000000000000..7d02dae1f95c --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/system_defaults.json @@ -0,0 +1,9 @@ +{ + "SYSTEM_DEFAULTS_WITH_CORRECT_VALUES": { + "desc": "CONFIG SYSTEM_DEFAULTS TABLE WITH ALL THE CORRECT VALUES" + }, + "SYSTEM_DEFAULTS_WITH_INVALID_STATUS_VALUE" : { + "desc": "Referring invalid status value", + "eStrKey": "InvalidValue" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json new file mode 100644 index 000000000000..a8ccc13c099d --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_defaults.json @@ -0,0 +1,26 @@ +{ + "SYSTEM_DEFAULTS_WITH_CORRECT_VALUES": { + "sonic-system-defaults:sonic-system-defaults": { + "sonic-system-defaults:SYSTEM_DEFAULTS": { + "SYSTEM_DEFAULTS_LIST": [ + { + "name": "tunnel_qos_remap", + "status": "enabled" + } + ] + } + } + }, + "SYSTEM_DEFAULTS_WITH_INVALID_STATUS_VALUE": { + "sonic-system-defaults:sonic-system-defaults": { + "sonic-system-defaults:SYSTEM_DEFAULTS": { + "SYSTEM_DEFAULTS_LIST": [ + { + "name": "tunnel_qos_remap", + "status": "invalid_status" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-system-defaults.yang b/src/sonic-yang-models/yang-models/sonic-system-defaults.yang new file mode 100644 index 000000000000..a5160899777a --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-system-defaults.yang @@ -0,0 +1,39 @@ +module sonic-system-defaults{ + + yang-version 1.1; + + namespace "http://github.com/Azure/system-defaults"; + prefix system-defaults; + + import sonic-types { + prefix stypes; + } + + description "SYSTEM_DEFAULTS Table yang Module for SONiC"; + + container sonic-system-defaults { + + container SYSTEM_DEFAULTS { + + description "system_defaults table in config_db.json"; + + list SYSTEM_DEFAULTS_LIST { + + key "name"; + + leaf name { + description "feature name in SYSTEM_DEFAULTS table"; + type string { + length 1..32; + } + } + + leaf status { + description "default status of the feature"; + type stypes:admin_mode; + } + + } + } + } +}