Skip to content

Commit

Permalink
Add Yang model for SYSTEM_DEFAULTS table (#15129)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bingwang-ms authored May 18, 2023
1 parent 3521c29 commit fd59559
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
==============
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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',
Expand Down Expand Up @@ -175,6 +176,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',
Expand Down
5 changes: 5 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,11 @@
"TYPE": "RW"
}
},
"SYSTEM_DEFAULTS": {
"tunnel_qos_remap": {
"status": "enabled"
}
},
"LOSSLESS_TRAFFIC_PATTERN": {
"AZURE": {
"mtu": "1024",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
}
39 changes: 39 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-system-defaults.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module sonic-system-defaults{

yang-version 1.1;

namespace "https://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;
}

}
}
}
}

0 comments on commit fd59559

Please sign in to comment.