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

Update TELEMETRY_CLIENT YANG model #16861

Merged
merged 6 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Table of Contents
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
* [Telemetry client](#telemetry-client)
* [Tunnel](#tunnel)
* [Versions](#versions)
* [VLAN](#vlan)
Expand Down Expand Up @@ -2099,6 +2100,31 @@ and is listed in this table.
}
```

### Telemetry client

```
{
"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"
}
}
}
```

### Tunnel

This table configures the MUX tunnel for Dual-ToR setup
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1211,10 +1211,10 @@
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"DestinationGroup_HS": {
"DestinationGroup|HS": {
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
},
"Subscription_HS_RDMA": {
"Subscription|HS_RDMA": {
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
"TELEMETRY_CLIENT_LIST": [
{
"prefix": "DestinationGroup_HS",
"prefix": "DestinationGroup",
"name": "HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
},
{
"prefix": "Subscription_HS_RDMA",
"prefix": "Subscription",
"name": "HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand All @@ -36,15 +36,15 @@
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
"TELEMETRY_CLIENT_LIST": [
{
"prefix": "DestinationGroup_HS",
"prefix": "DestinationGroup",
"name": "HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
},
{
"prefix": "Subscription_HS_RDMA",
"prefix": "Subscription",
"name": "HS_RDMA",
"dst_group": "FS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand All @@ -64,15 +64,15 @@
"src_ip": "30.57.185.388",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
"TELEMETRY_CLIENT_LIST": [
{
"prefix": "DestinationGroup_HS",
"prefix": "DestinationGroup",
"name": "HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
},
{
"prefix": "Subscription_HS_RDMA",
"prefix": "Subscription",
"name": "HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand All @@ -92,15 +92,15 @@
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
"TELEMETRY_CLIENT_LIST": [
{
"prefix": "DestinationGroup_HS",
"prefix": "DestinationGroup",
"name": "HS",
"dst_addr": "30.57.186.214:8081,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
},
{
"prefix": "Subscription_HS_RDMA",
"prefix": "Subscription",
"name": "HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand All @@ -120,15 +120,15 @@
"src_ip": "30.57.185.38",
"unidirectional": "true"
},
"TELEMETRY_CLIENT_DS_LIST": [
"TELEMETRY_CLIENT_LIST": [
{
"prefix": "DestinationGroup_HS",
"prefix": "DestinationGroup",
"name": "HS",
"dst_addr": "30.57.186.214:80819,30.57.185.39:8081"
}
],
"TELEMETRY_CLIENT_SUB_LIST": [
},
{
"prefix": "Subscription_HS_RDMA",
"prefix": "Subscription",
"name": "HS_RDMA",
"dst_group": "HS",
"path_target": "COUNTERS_DB",
"paths": "COUNTERS/Ethernet*,COUNTERS_PORT_NAME_MAP",
Expand All @@ -139,4 +139,4 @@
}
}
}
}
}
23 changes: 8 additions & 15 deletions src/sonic-yang-models/yang-models/sonic-telemetry_client.yang
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,26 @@ module sonic-telemetry_client {
}
}

list TELEMETRY_CLIENT_DS_LIST {
list TELEMETRY_CLIENT_LIST {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now fields from both DestinationGroup and Subscription keys mixed up. For example, earlier the field "dst_addr" was valid for DestinationGroup key only. Now it will be accepted for Subscription keys too. Better to segregate them using choice/case statements and guard them using a when statement. Like:

list TELEMETRY_CLIENT_LIST {
  key "prefix name";
  leaf prefix { ... }
  leaf name { ... }
  choice key_type {
    case destination-group {
      when "../prefix = 'DestinationGroup'";
      leaf dst_addr { ... }
    }
    case subscription {
      when "../prefix = 'Subscription'";
      // fields from old TELEMETRY_CLIENT_SUB_LIST 
    }
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sachinholla Hi, it seems a bug in choice statement. When using choice in any of yang model other than sonic-acl.yang, it will fail the yang validation.
I submitted the issue. Please check detail here: #17518

I suggest to merge this PR first. Then the field leaf can be enhanced after choice issue being fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay.. let us go ahead since the author of this yang already approved

ordered-by user;
key "prefix";
key "prefix name";

leaf prefix {
type string {
pattern "DestinationGroup_" + ".*";
pattern 'Subscription|DestinationGroup';
}
}

leaf dst_addr {
type ipv4-port;
leaf name {
type string;
}
}

list TELEMETRY_CLIENT_SUB_LIST {
ordered-by user;
key "prefix";

leaf prefix {
type string {
pattern "Subscription_" + ".*";
}
leaf dst_addr {
type ipv4-port;
}

leaf dst_group {
must "(contains(../../TELEMETRY_CLIENT_DS_LIST/prefix, current()))";
must "(contains(../../TELEMETRY_CLIENT_LIST/name, current()))";
type string;
}

Expand Down