[yang]SONiC Yang model support for Telemetry_client. (#12483) (#13314)

#### Why I did it
Create SONIC Yang model for Telemetry_client
#### How I did it
Defined Yang models  based on Guideline doc:
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md
and
https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md
#### How to verify it
Added test cases to verify it.
This commit is contained in:
NanQiSweeper 2023-03-10 02:13:32 +08:00 committed by GitHub
parent c4c621c614
commit ae71988b9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2532 additions and 2206 deletions

File diff suppressed because it is too large Load Diff

View File

@ -151,6 +151,7 @@ setup(
'./yang-models/sonic-system-tacacs.yang',
'./yang-models/sonic-system-radius.yang',
'./yang-models/sonic-telemetry.yang',
'./yang-models/sonic-telemetry_client.yang',
'./yang-models/sonic-gnmi.yang',
'./yang-models/sonic-tunnel.yang',
'./yang-models/sonic-types.yang',
@ -231,6 +232,7 @@ setup(
'./cvlyang-models/sonic-system-aaa.yang',
'./cvlyang-models/sonic-system-tacacs.yang',
'./cvlyang-models/sonic-telemetry.yang',
'./cvlyang-models/sonic-telemetry_client.yang',
'./cvlyang-models/sonic-gnmi.yang',
'./cvlyang-models/sonic-types.yang',
'./cvlyang-models/sonic-versions.yang',

View File

@ -1177,6 +1177,24 @@
"port": "50051"
}
},
"TELEMETRY_CLIENT": {
"Global": {
"encoding": "JSON_IETF",
"retry_interval": "30",
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"DestinationGroup_HS": {
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
},
"Subscription_HS_RDMA": {
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
},
"GNMI": {
"certs": {
"ca_crt": "/etc/sonic/credentials/dsmsroot.cer",

View File

@ -0,0 +1,23 @@
{
"PASSED": {
"desc": "telemetry_client passed"
},
"INCORRECT_DST_GROUP": {
"desc": "INCORRECT DST_GROUP FIELD IN TELEMETRY_CLIENT TABLE.",
"eStrKey" : "Must"
},
"SRC_IP_INCORRECT_FORMAT": {
"desc": "Add src ip which is not in correct ip-prefix format.",
"eStrKey" : "InvalidValue",
"eStr": ["src_ip"]
},
"ENCODING_WRONG_VALUE": {
"desc": "Configure wrong value for encoding.",
"eStrKey" : "InvalidValue",
"eStr": ["encoding"]
},
"DST_ADDR_INCORRECT_FORMAT": {
"desc": "Add dst_addr which is not in correct ip-port format.",
"eStrKey" : "Pattern"
}
}

View File

@ -0,0 +1,142 @@
{
"PASSED": {
"sonic-telemetry_client:sonic-telemetry_client": {
"sonic-telemetry_client:TELEMETRY_CLIENT": {
"Global": {
"encoding": "JSON_IETF",
"retry_interval": "30",
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
{
"prefix": "DestinationGroup_HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
{
"prefix": "Subscription_HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
]
}
}
},
"INCORRECT_DST_GROUP": {
"sonic-telemetry_client:sonic-telemetry_client": {
"sonic-telemetry_client:TELEMETRY_CLIENT": {
"Global": {
"encoding": "JSON_IETF",
"retry_interval": "30",
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
{
"prefix": "DestinationGroup_HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
{
"prefix": "Subscription_HS_RDMA",
"dst_group": "FS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
]
}
}
},
"SRC_IP_INCORRECT_FORMAT": {
"sonic-telemetry_client:sonic-telemetry_client": {
"sonic-telemetry_client:TELEMETRY_CLIENT": {
"Global": {
"encoding": "JSON_IETF",
"retry_interval": "30",
"src_ip": "30.57.185.388",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
{
"prefix": "DestinationGroup_HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
{
"prefix": "Subscription_HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
]
}
}
},
"ENCODING_WRONG_VALUE": {
"sonic-telemetry_client:sonic-telemetry_client": {
"sonic-telemetry_client:TELEMETRY_CLIENT": {
"Global": {
"encoding": "Unicode",
"retry_interval": "30",
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
{
"prefix": "DestinationGroup_HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
{
"prefix": "Subscription_HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
]
}
}
},
"DST_ADDR_INCORRECT_FORMAT": {
"sonic-telemetry_client:sonic-telemetry_client": {
"sonic-telemetry_client:TELEMETRY_CLIENT": {
"Global": {
"encoding": "JSON_IETF",
"retry_interval": "30",
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
{
"prefix": "DestinationGroup_HS",
"dst_addr": "30.57.186.214:80819,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
{
"prefix": "Subscription_HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
"report_interval": "5000",
"report_type": "periodic"
}
]
}
}
}
}

View File

@ -0,0 +1,140 @@
module sonic-telemetry_client {
yang-version 1.1;
namespace "http://github.com/sonic-net/sonic-telemetry_client";
prefix telemetry_client;
import ietf-inet-types {
prefix inet;
}
import sonic-types {
prefix stypes;
}
organization
"SONiC";
contact
"SONiC";
description
"TELEMETRY_CLIENT yang Module for SONiC OS";
revision 2023-01-12 {
description
"First revision";
}
typedef report-type {
type enumeration {
enum periodic;
enum stream;
enum once;
}
}
typedef path_target {
type enumeration {
enum APPL_DB;
enum CONFIG_DB;
enum COUNTERS_DB;
enum STATE_DB;
enum OTHERS;
}
}
typedef encoding {
type enumeration {
enum JSON_IETF;
enum ASCII;
enum BYTES;
enum PROTO;
}
}
typedef ipv4-port {
type string {
pattern
'((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+ '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]):'
+ '([0-9]|[1-9]\d{1,3}|[1-5]\d{1,4}|6[0-4]\d{1,3}|65[0-4]\d{1,2}|655[0-2][0-9]|6553[0-5]),?)+';
}
}
container sonic-telemetry_client{
container TELEMETRY_CLIENT {
container Global {
leaf retry_interval {
type uint64;
description "retry_interval unit s";
}
leaf src_ip {
type inet:ip-address;
}
leaf encoding {
type encoding;
}
leaf unidirectional {
type boolean;
default true;
}
}
list TELEMETRY_CLIENT_DS_LIST {
ordered-by user;
key "prefix";
leaf prefix {
type string {
pattern "DestinationGroup_" + ".*";
}
}
leaf dst_addr {
type ipv4-port;
}
}
list TELEMETRY_CLIENT_SUB_LIST {
ordered-by user;
key "prefix";
leaf prefix {
type string {
pattern "Subscription_" + ".*";
}
}
leaf dst_group {
must "(contains(../../TELEMETRY_CLIENT_DS_LIST/prefix, current()))";
type string;
}
leaf path_target {
type path_target;
}
leaf paths {
type string;
}
leaf report_interval {
type uint64;
description "report_interval unit ms";
default 5000;
}
leaf report_type {
type report-type;
}
}
}
}
}