The YANG (Yet Another Next Generation) data modeling language is widely used in network configuration and data representation. This tutorial guides you through the installation and use of pyang
, a YANG validator, converter, and code generator, to inspect the YANG info for Nokia 7×50 models.
Step 1: Setting up a Virtual Environment
First, we’ll set up a virtual environment to keep our working space isolated.
- Make sure you have
python3
andgit
installed. - Create a new virtual environment using for example:
mkdir pyang
cd pyang
python3 -m venv .
source ./bin/activate
Step 2: Installing pyang
- Now, within our activated virtual environment, we’ll install pyang.
pip3 install pyang
Step 3: Cloning Nokia 7×50 YANG Models from GitHub
Clone the repository containing the models.
git clone https://github.com/nokia/7x50_YangModels.git
Now you have all the Yang files and releases. Change into the appropriate directory like the following:
cd 7x50_YangModels/latest_sros_23.3/nokia-combined
Step 4: Using pyang to Inspect the YANG Info
We’ll now use pyang
to inspect the specific path /configure/router/pcep/pcc
within the nokia-conf.yang
model.
pyang nokia-conf.yang -f tree --tree-path '/configure/router/pcep/pcc' --tree-depth 6
Output:
module: nokia-conf
+--rw configure
+--rw router* [router-name]
+--rw pcep
+--rw pcc!
+--rw ...
...
+--rw pce-associations
+--rw diversity* [assoc-name]
| ...
+--rw policy* [assoc-name]
...
This output provides a tree representation of the nokia-conf.yang
module, focusing on the path /configure/router/pcep/pcc
.
Wrapping up
You’ve now learned how to set up a virtual environment, install pyang
, clone the Nokia 7×50 YANG models, and use pyang
to inspect a specific YANG model path. This is essential for understanding the structure and details of YANG models, which can be invaluable when configuring or understanding network devices and systems.
See ya!