Skip to content

Commit

Permalink
Merge pull request #328 from arlakshm/arlakshm/202205/port_yang
Browse files Browse the repository at this point in the history
[202205] Port the yang-models for sonic-console.yang and sonic-restapi.yang
  • Loading branch information
gechiang authored Apr 18, 2024
2 parents c97be17 + f3fb253 commit ecb1cb9
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Table of Contents
* [Cable length](#cable-length)
* [Chassis module](#chassis-module)
* [COPP_TABLE](#copp_table)
* [Console](#console)
* [CRM](#crm)
* [Data Plane L3 Interfaces](#data-plane-l3-interfaces)
* [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER)
Expand Down Expand Up @@ -51,7 +52,8 @@ Table of Contents
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
* [Sflow](#sflow)
* [Sflow](#sflow)
* [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 @@ -714,6 +716,29 @@ It currently allows user to administratively bring down a line-card or fabric-ca
}
```

### Console

```
{
"CONSOLE_PORT": {
"1": {
"baud_rate": "115200",
"flow_control": "0",
"remote_device": "host-1"
},
"2": {
"baud_rate": "9600",
"flow_control": "1"
}
},
"CONSOLE_SWITCH": {
"console_mgmt": {
"enabled": "yes"
}
}
}
```

### CRM

```
Expand Down Expand Up @@ -1509,6 +1534,25 @@ 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"
},
"config": {
"client_auth": "true",
"log_level": "trace",
"allow_insecure": "false"
}
}
```

### Sflow

The below are the tables and their schema for SFLOW feature
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 @@ -99,6 +99,7 @@ def run(self):
'./yang-models/sonic-cable-length.yang',
'./yang-models/sonic-chassis-module.yang',
'./yang-models/sonic-copp.yang',
'./yang-models/sonic-console.yang',
'./yang-models/sonic-crm.yang',
'./yang-models/sonic-default-lossless-buffer-parameter.yang',
'./yang-models/sonic-device_metadata.yang',
Expand Down Expand Up @@ -130,6 +131,7 @@ def run(self):
'./yang-models/sonic-policer.yang',
'./yang-models/sonic-portchannel.yang',
'./yang-models/sonic-pfcwd.yang',
'./yang-models/sonic-restapi.yang',
'./yang-models/sonic-route-common.yang',
'./yang-models/sonic-route-map.yang',
'./yang-models/sonic-routing-policy-sets.yang',
Expand Down
29 changes: 29 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 @@ -1122,6 +1122,19 @@
"lanes": "1"
}
},
"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"
},
"config": {
"client_auth": "true",
"log_level": "trace",
"allow_insecure": "false"
}
},
"FLEX_COUNTER_TABLE": {
"PFCWD": {
"FLEX_COUNTER_STATUS": "enable"
Expand Down Expand Up @@ -2036,6 +2049,22 @@
"default_dynamic_th": "0",
"over_subscribe_ratio": "0"
}
},
"CONSOLE_PORT": {
"1": {
"baud_rate": "115200",
"flow_control": "0",
"remote_device": "host-1"
},
"2": {
"baud_rate": "9600",
"flow_control": "1"
}
},
"CONSOLE_SWITCH": {
"console_mgmt": {
"enabled": "yes"
}
}
},
"SAMPLE_CONFIG_DB_UNKNOWN": {
Expand Down
40 changes: 40 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/console.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"CONSOLE_DISABLED": {
"desc": "Verifying CONSOLE_SWITCH configuration."
},
"CONSOLE_DEFAULT_CONSOLE_MGMT": {
"desc": "CONSOLE_SWITCH default value for console_mgmt enabled field.",
"eStrKey": "Verify",
"verify": {
"xpath": "/sonic-console:sonic-console/CONSOLE_SWITCH/console_mgmt/enabled",
"key": "sonic-console:enabled",
"value": "no"
}
},
"CONSOLE_DISABLED_INCORRECT_PATTERN": {
"desc": "CONSOLE_SWITCH configuration pattern failure.",
"eStrKey": "Pattern"
},
"CONSOLE_PORT_DEFAULT_FLOW_CONTROL": {
"desc": "CONSOLE_PORT default value for flow_control field.",
"eStrKey": "Verify",
"verify": {
"xpath": "/sonic-console:sonic-console/CONSOLE_PORT/CONSOLE_PORT_LIST[name='1']/flow_control",
"key": "sonic-console:flow_control",
"value": "0"
}
},
"CONSOLE_PORT_INVALID_NAME": {
"desc": "CONSOLE_PORT invalid name failure.",
"eStrKey": "InvalidValue",
"eStr": ["name"]
},
"CONSOLE_PORT_INVALID_BAUD": {
"desc": "CONSOLE_PORT invalid baud failure.",
"eStrKey": "InvalidValue",
"eStr": ["baud"]
},
"CONSOLE_PORT_VALID": {
"desc": "Verifying CONSOLE_PORT configuration no failure."
}
}
16 changes: 16 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/restapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
"desc": "RESTAPI TABLE_WITH_INCORRECT_CERT failure.",
"eStr": ["Value", "does not satisfy the constraint"]
},
"RESTAPI_TABLE_WITH_INCORRECT_CLIENT": {
"desc": "RESTAPI TABLE_WITH_INCORRECT_CLIENT failure.",
"eStr": ["Value", "does not satisfy the constraint"]
},
"RESTAPI_TABLE_WITH_VALID_CONFIG": {
"desc": "RESTAPI TABLE WITH VALID CONFIG."
},
"RESTAPI_TABLE_WITH_MULTIPLE_CERTS": {
"desc": "RESTAPI TABLE WITH MULTIPLE CERTS."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"CONSOLE_DISABLED": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_SWITCH": {
"sonic-console:console_mgmt": {
"enabled": "no"
}
}
}
},
"CONSOLE_DEFAULT_CONSOLE_MGMT": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_SWITCH": {
"sonic-console:console_mgmt": {
}
}
}
},
"CONSOLE_DISABLED_INCORRECT_PATTERN": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_SWITCH": {
"sonic-console:console_mgmt": {
"enabled": "false"
}
}
}
},
"CONSOLE_PORT_DEFAULT_FLOW_CONTROL": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_PORT": {
"CONSOLE_PORT_LIST": [
{
"name": "1",
"baud_rate": "9600"
}
]
}
}
},
"CONSOLE_PORT_INVALID_NAME": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_PORT": {
"CONSOLE_PORT_LIST": [
{
"name": "invalid",
"baud_rate": "9600"
}
]
}
}
},
"CONSOLE_PORT_INVALID_BAUD": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_PORT": {
"CONSOLE_PORT_LIST": [
{
"name": "1",
"baud_rate": "invalid"
}
]
}
}
},
"CONSOLE_PORT_VALID": {
"sonic-console:sonic-console": {
"sonic-console:CONSOLE_PORT": {
"CONSOLE_PORT_LIST": [
{
"name": "1",
"baud_rate": "9600",
"flow_control": "1",
"remote_device": "remote_host_1"
},
{
"name": "2",
"baud_rate": "9600",
"flow_control": "0",
"remote_device": "remote_host_2"
},
{
"name": "3",
"baud_rate": "9600"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"RESTAPI_TABLE_WITH_INCORRECT_CERT": {
"sonic-restapi:sonic-restapi": {
"sonic-restapi:RESTAPI": {
"certs": {
"ca_crt": "/etc/sonic/credentials/ame_root.pem",
"server_crt": "a/b/c",
"server_key": "/etc/sonic/credentials/restapiserver.key",
"client_crt_cname": "client"
}
}
}
},
"RESTAPI_TABLE_WITH_INCORRECT_CLIENT": {
"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"
}
}
}
},
"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"
}
}
}
},
"RESTAPI_TABLE_WITH_MULTIPLE_CERTS": {
"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,clientds.prod.net"
}
}
}
}
}
Loading

0 comments on commit ecb1cb9

Please sign in to comment.