Skip to content

Commit fd59559

Browse files
authored
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
1 parent 3521c29 commit fd59559

File tree

6 files changed

+108
-1
lines changed

6 files changed

+108
-1
lines changed

src/sonic-yang-models/doc/Configuration.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Table of Contents
2828
* [DHCP_RELAY](#dhcp_relay)
2929
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
3030
* [FLEX_COUNTER_TABLE](#flex_counter_table)
31-
* [KDUMP](#kdump)
31+
* [KDUMP](#kdump)
3232
* [L2 Neighbors](#l2-neighbors)
3333
* [Loopback Interface](#loopback-interface)
3434
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
@@ -58,6 +58,7 @@ Table of Contents
5858
* [WRED_PROFILE](#wred_profile)
5959
* [PASSWORD_HARDENING](#password_hardening)
6060
* [RADIUS](#radius)
61+
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
6162
* [For Developers](#for-developers)
6263
* [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template)
6364
* [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
18011802
18021803
```
18031804

1805+
### SYSTEM_DEFAULTS table
1806+
To have a better management of the features in SONiC, a new table `SYSTEM_DEFAULTS` is introduced.
1807+
1808+
```
1809+
"SYSTEM_DEFAULTS": {
1810+
"tunnel_qos_remap": {
1811+
"status": "enabled"
1812+
}
1813+
"default_bgp_status": {
1814+
"status": "down"
1815+
}
1816+
"synchronous_mode": {
1817+
"status": "enable"
1818+
}
1819+
"dhcp_server": {
1820+
"status": "enable"
1821+
}
1822+
}
1823+
```
1824+
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.
1825+
1826+
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)
1827+
1828+
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`.
1829+
#### 5.2.3 Update value directly in db memory
18041830

18051831
For Developers
18061832
==============

src/sonic-yang-models/setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def run(self):
108108
'./yang-models/sonic-extension.yang',
109109
'./yang-models/sonic-flex_counter.yang',
110110
'./yang-models/sonic-feature.yang',
111+
'./yang-models/sonic-system-defaults.yang',
111112
'./yang-models/sonic-interface.yang',
112113
'./yang-models/sonic-kdump.yang',
113114
'./yang-models/sonic-loopback-interface.yang',
@@ -175,6 +176,7 @@ def run(self):
175176
'./cvlyang-models/sonic-extension.yang',
176177
'./cvlyang-models/sonic-flex_counter.yang',
177178
'./cvlyang-models/sonic-feature.yang',
179+
'./cvlyang-models/sonic-system-defaults.yang',
178180
'./cvlyang-models/sonic-interface.yang',
179181
'./cvlyang-models/sonic-kdump.yang',
180182
'./cvlyang-models/sonic-loopback-interface.yang',

src/sonic-yang-models/tests/files/sample_config_db.json

+5
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,11 @@
19541954
"TYPE": "RW"
19551955
}
19561956
},
1957+
"SYSTEM_DEFAULTS": {
1958+
"tunnel_qos_remap": {
1959+
"status": "enabled"
1960+
}
1961+
},
19571962
"LOSSLESS_TRAFFIC_PATTERN": {
19581963
"AZURE": {
19591964
"mtu": "1024",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"SYSTEM_DEFAULTS_WITH_CORRECT_VALUES": {
3+
"desc": "CONFIG SYSTEM_DEFAULTS TABLE WITH ALL THE CORRECT VALUES"
4+
},
5+
"SYSTEM_DEFAULTS_WITH_INVALID_STATUS_VALUE" : {
6+
"desc": "Referring invalid status value",
7+
"eStrKey": "InvalidValue"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"SYSTEM_DEFAULTS_WITH_CORRECT_VALUES": {
3+
"sonic-system-defaults:sonic-system-defaults": {
4+
"sonic-system-defaults:SYSTEM_DEFAULTS": {
5+
"SYSTEM_DEFAULTS_LIST": [
6+
{
7+
"name": "tunnel_qos_remap",
8+
"status": "enabled"
9+
}
10+
]
11+
}
12+
}
13+
},
14+
"SYSTEM_DEFAULTS_WITH_INVALID_STATUS_VALUE": {
15+
"sonic-system-defaults:sonic-system-defaults": {
16+
"sonic-system-defaults:SYSTEM_DEFAULTS": {
17+
"SYSTEM_DEFAULTS_LIST": [
18+
{
19+
"name": "tunnel_qos_remap",
20+
"status": "invalid_status"
21+
}
22+
]
23+
}
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module sonic-system-defaults{
2+
3+
yang-version 1.1;
4+
5+
namespace "http://github.com/Azure/system-defaults";
6+
prefix system-defaults;
7+
8+
import sonic-types {
9+
prefix stypes;
10+
}
11+
12+
description "SYSTEM_DEFAULTS Table yang Module for SONiC";
13+
14+
container sonic-system-defaults {
15+
16+
container SYSTEM_DEFAULTS {
17+
18+
description "system_defaults table in config_db.json";
19+
20+
list SYSTEM_DEFAULTS_LIST {
21+
22+
key "name";
23+
24+
leaf name {
25+
description "feature name in SYSTEM_DEFAULTS table";
26+
type string {
27+
length 1..32;
28+
}
29+
}
30+
31+
leaf status {
32+
description "default status of the feature";
33+
type stypes:admin_mode;
34+
}
35+
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)