Add Yang model for SYSTEM_DEFAULTS table (#15129)

Why I did it
This PR is to backport PR #11117 into 202205 branch.
This PR is to define Yang model for SYSTEM_DEFAULTS table.
The table was introduced in PR sonic-net/SONiC#982
The table will be like

"SYSTEM_DEFAULTS": {
        "tunnel_qos_remap": {
            "status": "enabled"
        }
}
Work item tracking
Microsoft ADO (https://msazure.visualstudio.com/One/_workitems/edit/23037078)
How I did it
Add a new yang file sonic-system-defaults. Yang.

How to verify it
Verified by UT
This commit is contained in:
bingwang-ms 2023-05-18 15:01:48 -07:00 committed by GitHub
parent 3521c29704
commit fd5955956b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 1 deletions

View File

@ -28,7 +28,7 @@ Table of Contents
* [DHCP_RELAY](#dhcp_relay)
* [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)
@ -58,6 +58,7 @@ Table of Contents
* [WRED_PROFILE](#wred_profile)
* [PASSWORD_HARDENING](#password_hardening)
* [RADIUS](#radius)
* [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)
@ -1801,6 +1802,31 @@ The RADIUS and RADIUS_SERVER tables define RADIUS config paramerters. RADIUS tab
```
### 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
==============

View File

@ -108,6 +108,7 @@ setup(
'./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',
@ -175,6 +176,7 @@ setup(
'./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',

View File

@ -1954,6 +1954,11 @@
"TYPE": "RW"
}
},
"SYSTEM_DEFAULTS": {
"tunnel_qos_remap": {
"status": "enabled"
}
},
"LOSSLESS_TRAFFIC_PATTERN": {
"AZURE": {
"mtu": "1024",

View File

@ -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"
}
}

View File

@ -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"
}
]
}
}
}
}

View File

@ -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;
}
}
}
}
}