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

Add YANG model and unit tests for sonic-telemetry #10840

Merged
merged 17 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
24 changes: 22 additions & 2 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Table of Contents
* [Queue](#queue)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Versions](#versions)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
* [Versions](#versions)
Copy link
Collaborator

@qiluo-msft qiluo-msft May 17, 2022

Choose a reason for hiding this comment

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

[](http://example.com/codeflow?start=32&length=4)

Do not add unnecessary trailing blanks. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
* [Virtual router](#virtual-router)
Expand Down Expand Up @@ -1353,6 +1354,25 @@ name as object key and member list as attribute.
}
```

### Telemetry

```
{
"TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
}
}
```

### Versions

This table is where the curret version of the software is recorded.
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 @@ -126,6 +126,7 @@ def run(self):
'./yang-models/sonic-syslog.yang',
'./yang-models/sonic-system-aaa.yang',
'./yang-models/sonic-system-tacacs.yang',
'./yang-models/sonic-telemetry.yang',
'./yang-models/sonic-types.yang',
'./yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang',
Expand Down Expand Up @@ -184,6 +185,7 @@ def run(self):
'./cvlyang-models/sonic-sflow.yang',
'./cvlyang-models/sonic-system-aaa.yang',
'./cvlyang-models/sonic-system-tacacs.yang',
'./cvlyang-models/sonic-telemetry.yang',
'./cvlyang-models/sonic-types.yang',
'./cvlyang-models/sonic-versions.yang',
'./cvlyang-models/sonic-vlan.yang',
Expand Down
14 changes: 13 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,18 @@
"VERSION": "version_1_0_3"
}
},
"TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
},
"FLEX_COUNTER_TABLE": {
"PFCWD": {
"FLEX_COUNTER_STATUS": "enable"
Expand Down Expand Up @@ -1516,7 +1528,7 @@
"pir": "2560000",
"type": "STRICT"
}
},
},

"WRED_PROFILE": {
"Wred1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"TELEMETRY_TABLE_WITH_INCORRECT_CERT": {
"desc": "TABLE_WITH_INCORRECT_CERT failure.",
"eStrKey": "Pattern"
},
"TELEMETRY_TABLE_WITH_INCORRECT_CLIENT_AUTH": {
"desc": "TABLE_WITH_INCORRECT_CLIENT_AUTH failure",
"eStrKey": "InvalidValue"
},
"TELEMETRY_TABLE_WITH_INCORRECT_PORT": {
"desc": "TABLE_WITH_INCORRECT_PORT failure.",
"eStrKey": "InvalidValue"
},
"TELEMETRY_TABLE_WITH_VALID_CONFIG": {
"desc": "TABLE WITH VALID CONFIG."
Copy link
Collaborator

@qiluo-msft qiluo-msft May 17, 2022

Choose a reason for hiding this comment

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

Mixing tabs/spaces. Prefer 4-space indentation. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"TELEMETRY_TABLE_WITH_INCORRECT_CERT": {
"sonic-telemetry:sonic-telemetry": {
"sonic-telemetry:TELEMETRY": {
"certs": {
"ca_crt": "abcd.config",
"server_crt": "a/b/c",
"server_key": "123"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
}
}
},
"TELEMETRY_TABLE_WITH_INCORRECT_CLIENT_AUTH": {
"sonic-telemetry:sonic-telemetry": {
"sonic-telemetry:TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
Copy link
Collaborator

@qiluo-msft qiluo-msft May 17, 2022

Choose a reason for hiding this comment

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

       [](http://example.com/codeflow?start=0&length=6)

Mixing tabs/spaces. Prefer 4-space indentation. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "up",
"log_level": "2",
"port": "50051"
}
}
}
},
"TELEMETRY_TABLE_WITH_INCORRECT_PORT": {
"sonic-telemetry:sonic-telemetry": {
"sonic-telemetry:TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "abc"
}
}
}
},
"TELEMETRY_TABLE_WITH_VALID_CONFIG": {
"sonic-telemetry:sonic-telemetry": {
"sonic-telemetry:TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
}
}
}
}
78 changes: 78 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-telemetry.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module sonic-telemetry {

yang-version 1.1;

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

import ietf-inet-types {
prefix inet;
}

organization
"SONiC";

contact
"SONiC";

description "TELEMETRY YANG Module for SONiC OS";

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

container sonic-telemetry {

container TELEMETRY {

description "TELEMETRY TABLE part of config_db.json";

container certs {

leaf ca_crt {
type string {
pattern '(/[a-zA-Z0-9_-]+)*/dsmsroot.cer';
Copy link
Collaborator

@qiluo-msft qiluo-msft May 17, 2022

Choose a reason for hiding this comment

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

dsmsroot.cer

Is this pattern enforced by sonic-telemetry implementation? If not, we can relax. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to:

https://github.com/Azure/sonic-mgmt/blob/a51f9fa3125ebca8a60f8e55c7f46eaf8a0e5754/ansible/group_vars/all/telemetry_certs.yml,

All telemetry certs will have the exact path listed. Maybe it makes sense to enforce the entire path instead of just the file name and extension.

Copy link
Contributor

Choose a reason for hiding this comment

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

The file name must be dsmsroot.cer? Can we use other name like abc.cer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed pattern to not include filename in the case that file name changes in the future.

}
description "Local path for ca_crt.";
}

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

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

}

container gnmi {

leaf client_auth {
type boolean;
description "Flag for requiring client auth.";
}

leaf log_level {
type uint8 {
range 0..100;
}
description "Log level for gnmi.";
}

leaf port {
type inet:port-number;
description "Port gnmi runs on.";
}

}

}
}
}