Add a yang model for the new "Logger" table in the CONFIG DB (#12067)

- Why I did it
Add the ability to the user to save the loglevel and make it persistent to reboot.

- How I did it
Move the logger tables from the LOGLEVEL DB to the CONFIG DB. Add new yang model to verify the new config schema.

- How to verify it
1. change the orchagent loglevel (for example) -> swssloglevel -c orchagent -l DEBUG
2. save the loglevel -> run config save
3. reboot
4. verify that the orchagent log level is still DEBUG ->run run redis-cli -n 4 hgetall "LOGGER|orchagent"
This commit is contained in:
EdenGri 2022-10-31 10:42:12 +02:00 committed by GitHub
parent d1df2843fa
commit 6bed69af6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 191 additions and 0 deletions

View File

@ -58,6 +58,7 @@ Table of Contents
* [VOQ Inband Interface](#voq-inband-interface)
* [VXLAN](#vxlan)
* [Virtual router](#virtual-router)
* [LOGGER](#logger)
* [WRED_PROFILE](#wred_profile)
* [PASSWORD_HARDENING](#password_hardening)
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
@ -1705,6 +1706,34 @@ The packet action could be:
}
}
```
### Logger
In this table, the loglevel and logoutput of the components are defined. Each component
will have the component name as its key; and LOGLEVEL and LOGOUTPUT as attributes.
The LOGLEVEL attribute will define the verbosity of the component.
The LOGOUTPUT attribute will define the file of printing the logs.
```
{
"LOGGER": {
"orchagent": {
"LOGLEVEL": "NOTICE",
"LOGOUTPUT": "SYSLOG"
},
"syncd": {
"LOGLEVEL": "DEBUG",
"LOGOUTPUT": "STDOUT"
},
"SAI_API_LAG": {
"LOGLEVEL": "ERROR",
"LOGOUTPUT": "STDERR"
}
}
}
```
### PASSWORD_HARDENING
Password Hardening, a user password is the key credential used in order to verify the user accessing the switch and acts as the first line of defense in regards to securing the switch. PASSWORD_HARDENING - support the enforce strong policies.

View File

@ -169,6 +169,7 @@ setup(
'./yang-models/sonic-peer-switch.yang',
'./yang-models/sonic-pfc-priority-queue-map.yang',
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
'./yang-models/sonic-logger.yang',
'./yang-models/sonic-port-qos-map.yang',
'./yang-models/sonic-static-route.yang',
'./yang-models/sonic-macsec.yang']),
@ -234,6 +235,7 @@ setup(
'./cvlyang-models/sonic-tc-queue-map.yang',
'./cvlyang-models/sonic-pfc-priority-queue-map.yang',
'./cvlyang-models/sonic-pfc-priority-priority-group-map.yang',
'./cvlyang-models/sonic-logger.yang',
'./cvlyang-models/sonic-port-qos-map.yang',
'./cvlyang-models/sonic-static-route.yang',
'./cvlyang-models/sonic-macsec.yang']),

View File

@ -837,6 +837,20 @@
"tpid": "0x8100"
}
},
"LOGGER": {
"orchagent": {
"LOGLEVEL": "NOTICE",
"LOGOUTPUT": "SYSLOG"
},
"syncd": {
"LOGLEVEL": "NOTICE",
"LOGOUTPUT": "SYSLOG"
},
"SAI_API_LAG": {
"LOGLEVEL": "SAI_LOG_LEVEL_NOTICE",
"LOGOUTPUT": "SYSLOG"
}
},
"ACL_TABLE": {
"V4-ACL-TABLE": {
"type": "L3",

View File

@ -0,0 +1,18 @@
{
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": {
"desc": "LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT_1 no failure."
},
"LOGGER_WRONG_LOGLEVEL": {
"desc": "LOGGER_WRONG_LOGLEVEL pattern failure.",
"eStr": ["wrong", "LOGLEVEL"]
},
"LOGGER_WRONG_LOGOUTPUT": {
"desc": "LOGGER_WRONG_LOGOUTPUT pattern failure.",
"eStr": ["wrong", "LOGOUTPUT"]
},
"LOGGER_MANDATORY_LOGLEVEL": {
"desc": "LOGGER_MANDATORY_LOGOUTPUT no logoutput.",
"estr": ["LOGLEVEL"],
"eStrKey": "Mandatory"
}
}

View File

@ -0,0 +1,55 @@
{
"LOGGER_CORRECT_LOGLEVEL_AND_LOGOUTPUT": {
"sonic-logger:sonic-logger": {
"sonic-logger:LOGGER": {
"LOGGER_LIST": [{
"name": "orchagent",
"LOGLEVEL": "NOTICE",
"LOGOUTPUT": "SYSLOG"
},
{
"name": "syncd",
"LOGLEVEL": "DEBUG",
"LOGOUTPUT": "STDOUT"
},
{
"name": "SAI_API_LAG",
"LOGLEVEL": "SAI_LOG_LEVEL_ERROR",
"LOGOUTPUT": "STDERR"
}]
}
}
},
"LOGGER_WRONG_LOGLEVEL": {
"sonic-logger:sonic-logger": {
"sonic-logger:LOGGER": {
"LOGGER_LIST": [{
"name": "orchagent",
"LOGLEVEL": "wrong",
"LOGOUTPUT": "SYSLOG"
}]
}
}
},
"LOGGER_WRONG_LOGOUTPUT": {
"sonic-logger:sonic-logger": {
"sonic-logger:LOGGER": {
"LOGGER_LIST": [{
"name": "orchagent",
"LOGLEVEL": "NOTICE",
"LOGOUTPUT": "wrong"
}]
}
}
},
"LOGGER_MANDATORY_LOGLEVEL": {
"sonic-logger:sonic-logger": {
"sonic-logger:LOGGER": {
"LOGGER_LIST": [{
"name": "orchagent",
"LOGOUTPUT": "SYSLOG"
}]
}
}
}
}

View File

@ -0,0 +1,73 @@
module sonic-logger{
yang-version 1.1;
namespace "http://github.com/Azure/sonic-logger";
prefix logger;
import sonic-types {
prefix stypes;
}
description "Logger Table yang Module for SONiC";
typedef swss_loglevel {
type enumeration {
enum EMERG;
enum ALERT;
enum CRIT;
enum ERROR;
enum WARN;
enum NOTICE;
enum INFO;
enum DEBUG;
}
}
typedef sai_loglevel {
type enumeration {
enum SAI_LOG_LEVEL_CRITICAL;
enum SAI_LOG_LEVEL_ERROR;
enum SAI_LOG_LEVEL_WARN;
enum SAI_LOG_LEVEL_NOTICE;
enum SAI_LOG_LEVEL_INFO;
enum SAI_LOG_LEVEL_DEBUG;
}
}
container sonic-logger {
container LOGGER {
description "Logger table in config_db.json";
list LOGGER_LIST {
key "name";
leaf name {
description "Component name in LOGGER table (example for component: orchagent, Syncd, SAI components).";
type string;
}
leaf LOGLEVEL {
description "The log verbosity for the component";
mandatory true;
type union {
type swss_loglevel;
type sai_loglevel;
}
}
leaf LOGOUTPUT {
type enumeration {
enum SYSLOG;
enum STDOUT;
enum STDERR;
}
default SYSLOG;
}
}/* end of list LOGGER_LIST */
}/* end of LOGGER container */
}/* end of sonic-logger container */
}/* end of sonic-logger module */