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

[Yang model] add Restapi yang file #12287

Merged
merged 2 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Table of Contents
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
* [Restapi](#restapi)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
Expand Down Expand Up @@ -1411,6 +1412,18 @@ name as object key and member list as attribute.
}
```

### Restapi
```
{
"RESTAPI": {
"certs": {
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
"server_key": "/etc/sonic/credentials/restapiserver.key",
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
"client_crt_cname": "client.sonic.net"
}
}
```

### Tacplus Server

Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def run(self):
'./yang-models/sonic-scheduler.yang',
'./yang-models/sonic-wred-profile.yang',
'./yang-models/sonic-queue.yang',
'./yang-models/sonic-restapi.yang',
'./yang-models/sonic-dscp-fc-map.yang',
'./yang-models/sonic-exp-fc-map.yang',
'./yang-models/sonic-dscp-tc-map.yang',
Expand Down
8 changes: 8 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 @@ -1118,6 +1118,14 @@
"port": "50051"
}
},
"RESTAPI": {
"certs": {
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
"server_key": "/etc/sonic/credentials/restapiserver.key",
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
"client_crt_cname": "client.sonic.net"
}
},
"FLEX_COUNTER_TABLE": {
"PFCWD": {
"FLEX_COUNTER_STATUS": "enable"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
"desc": "TABLE_WITH_INCORRECT_CERT failure.",
"eStrKey": "Pattern"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"eStr": ["server_crt"]

This way, Libyang error will be matched against only server_crt field.

},
"RESTAPI_TABLE_WITH_VALID_CONFIG": {
"desc": "TABLE WITH VALID CONFIG."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"RESTAPI TABLE WITH VALID CONFIG."

Desc is helpful in case of test failures. Thx

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
"sonic-restapi:sonic-restapi": {
"sonic-restapi:RESTAPI": {
"certs": {
"ca_crt": "abcd.config",
"server_crt": "a/b/c",
"server_key": "123",
"client_crt_cname": "client"
}
}
}
},
"RESTAPI_TABLE_WITH_VALID_CONFIG": {
"sonic-restapi:sonic-restapi": {
"sonic-restapi:RESTAPI": {
"certs": {
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
"server_crt": "/etc/sonic/credentials/restapiserver.crt",
"server_key": "/etc/sonic/credentials/restapiserver.key",
"client_crt_cname": "client.sonic.net"
}
}
}
}
}
63 changes: 63 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-restapi.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module sonic-restapi {

yang-version 1.1;

namespace "http://github.com/Azure/sonic-restapi";
prefix restapi;

import ietf-inet-types {
prefix inet;
}

organization
"SONiC";

contact
"SONiC";

description "RESTAPI YANG Module for SONiC OS";

revision 2022-10-05 {
description "First Revision";
}

container sonic-restapi {

container RESTAPI {

description "RESTAPI TABLE part of config_db.json";

container certs {

leaf ca_crt {
type string {
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).pem';
}
description "Local path for ca_crt.";
}

leaf server_crt {
type string {
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).crt';
}
Copy link
Contributor

@ganglyu ganglyu Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to limit the suffix as crt? Can we use xxx.cer or xxx.cert?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think for restapi, it is currently fixed to crt. We may not need to provide an extension support

description "Local path for server_crt.";
}

leaf client_crt_cname {
type string {
pattern '(/[a-zA-Z0-9_-.]+)*/([a-zA-Z0-9_-.]+)./[a-z]{3}';
}
description "Client cert name.";
}

leaf server_key {
type string {
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).key';
}
description "Local path for server_key.";
}

}
}
}
}