Skip to content

Commit

Permalink
Add a yang model for the new "Logger" table in the CONFIG DB (#12067)
Browse files Browse the repository at this point in the history
- 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"
  • Loading branch information
EdenGri authored Oct 31, 2022
1 parent d1df284 commit 6bed69a
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
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 @@ -169,6 +169,7 @@ def run(self):
'./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']),
Expand Down Expand Up @@ -234,6 +235,7 @@ def run(self):
'./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']),
Expand Down
14 changes: 14 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 @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/logger.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}]
}
}
}
}
73 changes: 73 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-logger.yang
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit 6bed69a

Please sign in to comment.