Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yang model for SYSTEM_DEFAULTS table #11117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
==============

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 @@ -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',
bingwang-ms marked this conversation as resolved.
Show resolved Hide resolved
'./yang-models/sonic-interface.yang',
'./yang-models/sonic-kdump.yang',
'./yang-models/sonic-loopback-interface.yang',
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1890,8 +1890,12 @@
"LAG"
]
}
},
"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 "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;
}

}
}
}
}