Skip to content

Commit e176512

Browse files
authored
[Yang model] add Restapi yang file (#12287)
* add Restapi Yang model
1 parent f182658 commit e176512

File tree

7 files changed

+121
-1
lines changed

7 files changed

+121
-1
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Table of Contents
4646
* [Scheduler](#scheduler)
4747
* [Port QoS Map](#port-qos-map)
4848
* [Queue](#queue)
49+
* [Restapi](#restapi)
4950
* [Tacplus Server](#tacplus-server)
5051
* [TC to Priority group map](#tc-to-priority-group-map)
5152
* [TC to Queue map](#tc-to-queue-map)
@@ -1411,6 +1412,18 @@ name as object key and member list as attribute.
14111412
}
14121413
```
14131414

1415+
### Restapi
1416+
```
1417+
{
1418+
"RESTAPI": {
1419+
"certs": {
1420+
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
1421+
"server_key": "/etc/sonic/credentials/restapiserver.key",
1422+
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
1423+
"client_crt_cname": "client.sonic.net"
1424+
}
1425+
}
1426+
```
14141427

14151428
### Tacplus Server
14161429

src/sonic-yang-models/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def run(self):
148148
'./yang-models/sonic-scheduler.yang',
149149
'./yang-models/sonic-wred-profile.yang',
150150
'./yang-models/sonic-queue.yang',
151+
'./yang-models/sonic-restapi.yang',
151152
'./yang-models/sonic-dscp-fc-map.yang',
152153
'./yang-models/sonic-exp-fc-map.yang',
153154
'./yang-models/sonic-dscp-tc-map.yang',

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

+8
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,14 @@
11181118
"port": "50051"
11191119
}
11201120
},
1121+
"RESTAPI": {
1122+
"certs": {
1123+
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
1124+
"server_key": "/etc/sonic/credentials/restapiserver.key",
1125+
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
1126+
"client_crt_cname": "client.sonic.net"
1127+
}
1128+
},
11211129
"FLEX_COUNTER_TABLE": {
11221130
"PFCWD": {
11231131
"FLEX_COUNTER_STATUS": "enable"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
3+
"desc": "RESTAPI TABLE_WITH_INCORRECT_CERT failure.",
4+
"eStr": ["server_crt"]
5+
},
6+
"RESTAPI_TABLE_WITH_VALID_CONFIG": {
7+
"desc": "RESTAPI TABLE WITH VALID CONFIG."
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
3+
"sonic-restapi:sonic-restapi": {
4+
"sonic-restapi:RESTAPI": {
5+
"certs": {
6+
"ca_crt": "abcd.config",
7+
"server_crt": "a/b/c",
8+
"server_key": "123",
9+
"client_crt_cname": "client"
10+
}
11+
}
12+
}
13+
},
14+
"RESTAPI_TABLE_WITH_VALID_CONFIG": {
15+
"sonic-restapi:sonic-restapi": {
16+
"sonic-restapi:RESTAPI": {
17+
"certs": {
18+
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
19+
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
20+
"server_key": "/etc/sonic/credentials/restapiserver.key",
21+
"client_crt_cname": "client.sonic.net"
22+
}
23+
}
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module sonic-restapi {
2+
3+
yang-version 1.1;
4+
5+
namespace "https://github.com/Azure/sonic-restapi";
6+
prefix restapi;
7+
8+
import ietf-inet-types {
9+
prefix inet;
10+
}
11+
12+
organization
13+
"SONiC";
14+
15+
contact
16+
"SONiC";
17+
18+
description "RESTAPI YANG Module for SONiC OS";
19+
20+
revision 2022-10-05 {
21+
description "First Revision";
22+
}
23+
24+
container sonic-restapi {
25+
26+
container RESTAPI {
27+
28+
description "RESTAPI TABLE part of config_db.json";
29+
30+
container certs {
31+
32+
leaf ca_crt {
33+
type string {
34+
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).pem';
35+
}
36+
description "Local path for ca_crt.";
37+
}
38+
39+
leaf server_crt {
40+
type string {
41+
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).crt';
42+
}
43+
description "Local path for server_crt.";
44+
}
45+
46+
leaf client_crt_cname {
47+
type string {
48+
pattern '(/[a-zA-Z0-9_-.]+)*/([a-zA-Z0-9_-.]+)./[a-z]{3}';
49+
}
50+
description "Client cert name.";
51+
}
52+
53+
leaf server_key {
54+
type string {
55+
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).key';
56+
}
57+
description "Local path for server_key.";
58+
}
59+
60+
}
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)