on 10-04-2018 01:02 PM
This document describes about how to derive yang path from a yang module. It’s challenging to get the sensor path info from the yang modules containing data models. Below section explains about how to get the a data model from a Yang module.
This can be used for both Cisco and openconfig specific yang modules.
Yang is a data modeling language used to model configs and provide real time state data.
https://github.com/YangModels/yang.git
NARVENKA$ git clone https://github.com/YangModels/yang.git
Cloning into 'yang'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 21976 (delta 0), reused 1 (delta 0), pack-reused 21974
Receiving objects: 100% (21976/21976), 42.41 MiB | 3.48 MiB/s, done.
Resolving deltas: 100% (17077/17077), done.
Checking out files: 100% (20902/20902), done.
NARVENKA$
NARVENKA$ cd yang/
NARVENKA$ ls
README.md experimental setup.py standard testall.sh tools vendor
NARVENKA$ cd vendor/
NARVENKA$ cd cisco/
NARVENKA$ ls
README.md check.sh common nx xe xr
NARVENKA$ cd xr/
NARVENKA$ ls
530 533 601 612 622 632 651
531 534 602 613 623 641 README.md
532 600 611 621 631 642 check.sh
NARVENKA$ cd 651/
NARVENKA$ pwd
/Users/macuser/yang/vendor/cisco/xr/651
https://github.com/YangModels/yang/tree/master/vendor/cisco/xr
3.5 Using pyang construct yang path
<Modulename:yang tree with leaf>
Cisco-IOS-XR-qos-ma-oper:qos/interface-table/interface/member-interfaces/member-interface/output
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-depth=1
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos --tree-depth=2
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro nv-interface-table
| ...
+--ro nv-satellite
| ...
+--ro nodes
| ...
+--ro qos-global
| ...
+--ro interface-table
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos/interface-table --tree-depth=3
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro interface-table
+--ro interface* [interface-name]
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos/interface-table/interface --tree-depth=4
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro interface-table
+--ro interface* [interface-name]
+--ro nodes
| ...
+--ro interface-name xr:Interface-name
+--ro member-interfaces
| ...
+--ro satellite-ids
| ...
+--ro input
| ...
+--ro output
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos/interface-table/interface/member-interfaces --tree-depth=5
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro interface-table
+--ro interface* [interface-name]
+--ro member-interfaces
+--ro member-interface* [interface-name]
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos/interface-table/interface/member-interfaces/member-interface --tree-depth=6
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro interface-table
+--ro interface* [interface-name]
+--ro member-interfaces
+--ro member-interface* [interface-name]
+--ro interface-name xr:Interface-name
+--ro satellite-ids
| ...
+--ro input
| ...
+--ro output
...
NARVENKA$ pyang -f tree Cisco-IOS-XR-qos-ma-oper.yang --tree-path=qos/interface-table/interface/member-interfaces/member-interface/output --tree-depth=7
module: Cisco-IOS-XR-qos-ma-oper
+--ro qos
+--ro interface-table
+--ro interface* [interface-name]
+--ro member-interfaces
+--ro member-interface* [interface-name]
+--ro output
+--ro service-policy-names
...
NARVENKA$
Now construct the sensor path including tree with respective leaf. In XR node sensor path configured under sensor group. Please refer the below example for validation.
sensor-path Cisco-IOS-XR-qos-ma-oper:qos/interface-table/interface/member-interfaces/member-interface/output
Example:
RP/0/RSP0/CPU0:BX03#conf terminal
RP/0/RSP0/CPU0:BX03(config)#telemetry model-driven
RP/0/RSP0/CPU0:BX03(config-model-driven)#sensor-group 1minute
RP/0/RSP0/CPU0:BX03(config-model-driven-snsr-grp)# sensor-path Cisco-IOS-XR-qos-ma-oper:qos/interface-table/interface/member-interfaces/member-interface/output
RP/0/RSP0/CPU0:BX03(config-model-driven-snsr-grp)#commit
RP/0/RSP0/CPU0:Sep 25 20:20:41.691 UTC: config[66977]: %MGBL-CONFIG-6-DB_COMMIT : Configuration committed by user 'narvenka'. Use 'show configuration commit changes 1000000386' to view the changes.
RP/0/RSP0/CPU0:BX03(config-model-driven-snsr-grp)#end
RP/0/RSP0/CPU0:Sep 25 20:20:43.069 UTC: config[66977]: %MGBL-SYS-5-CONFIG_I : Configured from console by narvenka
RP/0/RSP0/CPU0:BX03#
RP/0/RSP0/CPU0:BX03#
RP/0/RSP0/CPU0:BX03#show telemetry model-driven subscription
Subscription: 1minute State: NA
-------------
Sensor groups:
Id Interval(ms) State
1minute 60000 Resolved
RP/0/RSP0/CPU0:BX03#show telemetry model-driven subscription detail
Subscription:
-------------
State: NA
Collection Groups:
------------------
No active collection groups
RP/0/RSP0/CPU0:BX03#show telemetry model-driven subscription 1minute
Subscription: 1minute
-------------
State: NA
Sensor groups:
Id: 1minute
Sample Interval: 60000 ms
Sensor Path: Cisco-IOS-XR-asr9k-np-oper:hardware-module-np/nodes/node/nps/np/load-utilization
Sensor Path State: Resolved
Sensor Path: Cisco-IOS-XR-telemetry-model-driven-oper:telemetry-model-driven/destinations/destination
Sensor Path State: Resolved
Sensor Path: Cisco-IOS-XR-qos-ma-oper:qos/interface-table/interface/member-interfaces/member-interface/output
Sensor Path State: Resolved
Collection Groups:
------------------
No active collection groups
RP/0/RSP0/CPU0:BX03#
Also refer “Implementing GRPC/Telemetry on XR devices” for more info about implementation.
Nice Info. Thanks Venkat !!
hi @narvenka
my experience is that not all models listed in repo for specific version (https://github.com/YangModels/yang/tree/master/vendor/cisco/xr) are supported.
I found useful to check supported models via netconf: ssh <router> -s netconf
see more details here:
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: