Skip to content

Commit c3e358d

Browse files
authored
[action] [PR:25443] [yang] add yang model for console escape char config (#2178)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> Add config for console escape character under console_mgmt, CONSOLE_SWITCH #### Why I did it Add config for console escape character under console_mgmt, CONSOLE_SWITCH ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Add escape_char config under console_mgmt, CONSOLE_SWITCH #### How to verify it run against yang unit test <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [ ] 202511 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com> #### A picture of a cute animal (not mandatory but encouraged)
1 parent 7ab0841 commit c3e358d

4 files changed

Lines changed: 234 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,9 @@ It currently allows user to administratively bring down a line-card or fabric-ca
873873

874874
### Console
875875

876+
CONSOLE_PORT defines individual line configuration and CONSOLE_SWITCH defines global console config. The item default_escape_char and escape_char are optional. It can be
877+
set in CONSOLE_SWITCH or overridden in each CONSOLE_PORT config
878+
876879
```
877880
{
878881
"CONSOLE_PORT": {
@@ -883,12 +886,14 @@ It currently allows user to administratively bring down a line-card or fabric-ca
883886
},
884887
"2": {
885888
"baud_rate": "9600",
886-
"flow_control": "1"
889+
"flow_control": "1",
890+
"escape_char": "c"
887891
}
888892
},
889893
"CONSOLE_SWITCH": {
890894
"console_mgmt": {
891-
"enabled": "yes"
895+
"enabled": "yes",
896+
"default_escape_char": "b"
892897
}
893898
}
894899
}

src/sonic-yang-models/tests/yang_model_tests/tests/console.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,61 @@
3636
},
3737
"CONSOLE_PORT_VALID": {
3838
"desc": "Verifying CONSOLE_PORT configuration no failure."
39+
},
40+
"CONSOLE_SWITCH_VALID_DEFAULT_ESCAPE_CHAR": {
41+
"desc": "CONSOLE_SWITCH valid default_escape_char configuration."
42+
},
43+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_UPPERCASE": {
44+
"desc": "CONSOLE_SWITCH invalid default_escape_char with uppercase letter.",
45+
"eStrKey": "Pattern",
46+
"eStr": ["default_escape_char"]
47+
},
48+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_NUMBER": {
49+
"desc": "CONSOLE_SWITCH invalid default_escape_char with number.",
50+
"eStrKey": "Pattern",
51+
"eStr": ["default_escape_char"]
52+
},
53+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_SPECIAL": {
54+
"desc": "CONSOLE_SWITCH invalid default_escape_char with special character.",
55+
"eStrKey": "Pattern",
56+
"eStr": ["default_escape_char"]
57+
},
58+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_MULTIPLE": {
59+
"desc": "CONSOLE_SWITCH invalid default_escape_char with multiple characters.",
60+
"eStrKey": "Pattern",
61+
"eStr": ["default_escape_char"]
62+
},
63+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_EMPTY": {
64+
"desc": "CONSOLE_SWITCH invalid default_escape_char with empty string.",
65+
"eStrKey": "Pattern",
66+
"eStr": ["default_escape_char"]
67+
},
68+
"CONSOLE_PORT_VALID_ESCAPE_CHAR": {
69+
"desc": "CONSOLE_PORT valid escape_char configuration."
70+
},
71+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_UPPERCASE": {
72+
"desc": "CONSOLE_PORT invalid escape_char with uppercase letter.",
73+
"eStrKey": "Pattern",
74+
"eStr": ["escape_char"]
75+
},
76+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_NUMBER": {
77+
"desc": "CONSOLE_PORT invalid escape_char with number.",
78+
"eStrKey": "Pattern",
79+
"eStr": ["escape_char"]
80+
},
81+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_SPECIAL": {
82+
"desc": "CONSOLE_PORT invalid escape_char with special character.",
83+
"eStrKey": "Pattern",
84+
"eStr": ["escape_char"]
85+
},
86+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_MULTIPLE": {
87+
"desc": "CONSOLE_PORT invalid escape_char with multiple characters.",
88+
"eStrKey": "Pattern",
89+
"eStr": ["escape_char"]
90+
},
91+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_EMPTY": {
92+
"desc": "CONSOLE_PORT invalid escape_char with empty string.",
93+
"eStrKey": "Pattern",
94+
"eStr": ["escape_char"]
3995
}
4096
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/console.json

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,152 @@
8484
]
8585
}
8686
}
87+
},
88+
"CONSOLE_SWITCH_VALID_DEFAULT_ESCAPE_CHAR": {
89+
"sonic-console:sonic-console": {
90+
"sonic-console:CONSOLE_SWITCH": {
91+
"sonic-console:console_mgmt": {
92+
"enabled": "yes",
93+
"default_escape_char": "a"
94+
}
95+
}
96+
}
97+
},
98+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_UPPERCASE": {
99+
"sonic-console:sonic-console": {
100+
"sonic-console:CONSOLE_SWITCH": {
101+
"sonic-console:console_mgmt": {
102+
"enabled": "yes",
103+
"default_escape_char": "A"
104+
}
105+
}
106+
}
107+
},
108+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_NUMBER": {
109+
"sonic-console:sonic-console": {
110+
"sonic-console:CONSOLE_SWITCH": {
111+
"sonic-console:console_mgmt": {
112+
"enabled": "yes",
113+
"default_escape_char": "1"
114+
}
115+
}
116+
}
117+
},
118+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_SPECIAL": {
119+
"sonic-console:sonic-console": {
120+
"sonic-console:CONSOLE_SWITCH": {
121+
"sonic-console:console_mgmt": {
122+
"enabled": "yes",
123+
"default_escape_char": "!"
124+
}
125+
}
126+
}
127+
},
128+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_MULTIPLE": {
129+
"sonic-console:sonic-console": {
130+
"sonic-console:CONSOLE_SWITCH": {
131+
"sonic-console:console_mgmt": {
132+
"enabled": "yes",
133+
"default_escape_char": "ab"
134+
}
135+
}
136+
}
137+
},
138+
"CONSOLE_SWITCH_INVALID_DEFAULT_ESCAPE_CHAR_EMPTY": {
139+
"sonic-console:sonic-console": {
140+
"sonic-console:CONSOLE_SWITCH": {
141+
"sonic-console:console_mgmt": {
142+
"enabled": "yes",
143+
"default_escape_char": ""
144+
}
145+
}
146+
}
147+
},
148+
"CONSOLE_PORT_VALID_ESCAPE_CHAR": {
149+
"sonic-console:sonic-console": {
150+
"sonic-console:CONSOLE_PORT": {
151+
"CONSOLE_PORT_LIST": [
152+
{
153+
"name": "1",
154+
"baud_rate": "9600",
155+
"escape_char": "x"
156+
},
157+
{
158+
"name": "2",
159+
"baud_rate": "9600",
160+
"escape_char": "z"
161+
},
162+
{
163+
"name": "3",
164+
"baud_rate": "115200"
165+
}
166+
]
167+
}
168+
}
169+
},
170+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_UPPERCASE": {
171+
"sonic-console:sonic-console": {
172+
"sonic-console:CONSOLE_PORT": {
173+
"CONSOLE_PORT_LIST": [
174+
{
175+
"name": "1",
176+
"baud_rate": "9600",
177+
"escape_char": "X"
178+
}
179+
]
180+
}
181+
}
182+
},
183+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_NUMBER": {
184+
"sonic-console:sonic-console": {
185+
"sonic-console:CONSOLE_PORT": {
186+
"CONSOLE_PORT_LIST": [
187+
{
188+
"name": "1",
189+
"baud_rate": "9600",
190+
"escape_char": "5"
191+
}
192+
]
193+
}
194+
}
195+
},
196+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_SPECIAL": {
197+
"sonic-console:sonic-console": {
198+
"sonic-console:CONSOLE_PORT": {
199+
"CONSOLE_PORT_LIST": [
200+
{
201+
"name": "1",
202+
"baud_rate": "9600",
203+
"escape_char": "@"
204+
}
205+
]
206+
}
207+
}
208+
},
209+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_MULTIPLE": {
210+
"sonic-console:sonic-console": {
211+
"sonic-console:CONSOLE_PORT": {
212+
"CONSOLE_PORT_LIST": [
213+
{
214+
"name": "1",
215+
"baud_rate": "9600",
216+
"escape_char": "xy"
217+
}
218+
]
219+
}
220+
}
221+
},
222+
"CONSOLE_PORT_INVALID_ESCAPE_CHAR_EMPTY": {
223+
"sonic-console:sonic-console": {
224+
"sonic-console:CONSOLE_PORT": {
225+
"CONSOLE_PORT_LIST": [
226+
{
227+
"name": "1",
228+
"baud_rate": "9600",
229+
"escape_char": ""
230+
}
231+
]
232+
}
233+
}
87234
}
88235
}

src/sonic-yang-models/yang-models/sonic-console.yang

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,30 @@ module sonic-console {
99

1010
description "SONiC CONSOLE";
1111

12+
revision 2026-02-12 {
13+
description "Add escape_char config";
14+
}
15+
1216
revision 2022-08-22 {
1317
description "First Revision";
1418
}
1519

1620
typedef console-mgmt-enabled {
17-
description "configuration to set if console switch is enabled or not";
21+
description "Configuration to set if console switch is enabled or not";
1822
type string {
1923
pattern "yes|no";
2024
}
2125
}
2226

27+
typedef console-mgmt-escape-char {
28+
description "Configuration to set escape character when opening console line";
29+
type string {
30+
pattern '[a-z]';
31+
}
32+
}
33+
2334
typedef console-flow-control {
24-
description "configuration to set if enable flow control on a console port";
35+
description "Configuration to set if enable flow control on a console port";
2536
type string {
2637
pattern "0|1";
2738
}
@@ -54,6 +65,11 @@ module sonic-console {
5465
description "Configure the remote device name";
5566
type stypes:hostname;
5667
}
68+
69+
leaf escape_char {
70+
description "Override the global default_escape_char config";
71+
type console-mgmt-escape-char;
72+
}
5773
}
5874

5975
} /* end of container CONSOLE_PORT */
@@ -63,10 +79,15 @@ module sonic-console {
6379

6480
container console_mgmt {
6581
leaf enabled {
66-
description "This configuration indicate if enable console management feature on SONiC";
82+
description "This configuration indicates if enable console management feature on SONiC";
6783
type console-mgmt-enabled;
6884
default "no";
6985
}
86+
87+
leaf default_escape_char {
88+
description "This configuration provides the escape character for picocom";
89+
type console-mgmt-escape-char;
90+
}
7091
}
7192

7293
} /* end of container CONSOLE_SWITCH */

0 commit comments

Comments
 (0)