YANG Suite with NETCONF for Network Automation : A Simplified Guide – Part 1

In the last post, we looked at one of the popular ways to simplify the structure of a YANG module with the help of Pyang. In this two part series, we will take a look at another very popular tool that actually does much more than presenting YANG models in a tree like structure. The tool I am referring to is called YANG Suite. The simplicity of Pyang comes at the cost of feature functionality it can provide. While Pyang is a good option to simplify YANG modules in the initial phase, it starts to lose its charm as one begins to delve deeper into the world of Network Programmability. The table of contents is listed below. You can click on the links to jump to relevant sections.

  1. What’s YANG Suite ?
  2. Add a Device Profile
  3. Create Repository
  4. Create YANG Dataset

What’s YANG Suite ?

YANG Suite is a tool that provides a single web interface to programmatically interact with different network devices (IOS-XE, IOS-XR, NX-OS) through protocols like NETCONF, RESTCONF etc in conjunction with YANG models. It was developed & is maintained as an open source project. You can find the repo at the following link. YANG Suite can be installed using a Docker image or through PIP package manager. The installation is pretty straightforward and the following Github link provides details on both methods of installation.

https://github.com/CiscoDevNet/yangsuite

The following diagram provides a basic overview of the complete workflow. In this post, we will focus solely on the first 3 blocks that lay the foundation upon which we can run different operations on network devices.

Typical Workflow of a YANG Suite Operation
Fig 1 : Typical Workflow of a YANG Suite Operation

The first thing that we’ll need to do after installing YANG Suite is to configure it to interact with the network device. In our example, we will be using YANG Suite to interact with a CSR 1000V Router.

Add a Device Profile

  • In order to interact with a network device through YANG Suite, we first need to add it. We can do that by going to Setup –> Device Profiles
  • The following snapshot is from the “Device Profiles” page. We can add the network device by clicking on the “Create New Device” option. That will bring up the pop screens shown below. The data required is pretty self explanatory. We will need to pass on the IP Address, username, password etc. to complete the general & NETCONF configuration.
Network Device information
Fig 2 : Device information
Network Device NETCONF information
Fig 3 : NETCONF Details
  • Once the device has been created, we will see it listed like below. At this stage we can select the device and check it’s connectivity with YANG Suite by clicking on the “Check selected device’s reachability” option. If all goes well then we should see a successful outcome of the test.
List of added devices
Fig 4 : List of added devices
Results of device's reachability
Fig 5 : Results of device’s reachability

Create Repository

The next step after the addition of a network device is to create a repository in YANG Suite and associate that repo with YANG Modules.

  • Go to Setup –> YANG Files and Repositories. Click on “New Repository” and give it a name.
Create a new repository
Fig 6 : Create a new repository
Give a name to the repository
Fig 7 : Give a name to the repo
  • We will be presented with the following screen once the repo has been created. We can upload the YANG Module file by clicking on the “Upload files to repository” option.
Upload YANG modules to the repository
Fig 8 : Upload YANG modules
  • We can download different YANG Modules from the following link

https://github.com/YangModels/yang

  • If we are interested in a specific YANG module & want to work only with that specific module in YANG Suite then we will need to know its dependencies and import them into YANG Suite first. For example, we want to work only with YANG Module Cisco-IOS-XE-voice-oper.yang because we are only interested in the stats of voice traffic. The point to understand is that this module is referencing many other YANG modules within itself. This means that unless we import those other modules first, we will not be able to import Cisco-IOS-XE-voice-oper.yang. This is not all. Those other modules may have their own dependencies and their dependencies may have further dependencies. I hope you see where I am going with this. This can quickly morph into an unmanageable string which will be very hard to keep track of. This is evident from the following screenshot. I tried to import the Cisco-IOS-XE-voice-oper.yang module but it was unsuccessful because this module’s dependencies hadn’t been imported yet.
The "Missing Dependencies" conundrum
Fig 9 : The “Missing Dependencies” conundrum
  • The best way to get out of this situation is to import all YANG modules at once and then work with them individually as per our needs. As can be seen from the following snapshot, we no longer have the “missing dependencies” warning after importing every single module into the YANG Suite.
Successful upload of all YANG Modules
Fig 10 : Successful upload of all YANG Modules
  • This completes the repository configuration. The next step is to create a Dataset based on the YANG Modules.

Create YANG Dataset

  • Once the raw YANG data has been added to YANG Suite in the form of a repository, we then need to use that repository to create a Dataset. This is the set which will be used to interact with network devices.
  • We can initiate the process by clicking on Setup –> YANG Module Sets –> New YANG Set. Give a name to the dataset and associate it with the repository we created in the earlier section.
Create new YANG Data set
Fig 11 : Create new YANG Data set
Naming Data set and adding it to the repo
Fig 12 : Naming Data set and adding it to the repo
  • We now need to “fill” this newly created dataset with the modules which we’d added to the repository earlier. We can do that by selecting the modules in the right box and clicking on “Add Selected”
Selecting required modules
Fig 13 : Selecting required modules
Loading selected modules into Dataset
Fig 14 : Loading selected modules into Dataset
  • At this point, we can select any YANG module in the list and click on “View selected module” option to view it in the raw form similar to how it appears on the Github page.
  • This completes the base configuration required to initiate communication between the following three entities
    • YANG Suite
    • YANG Modules loaded in the Dataset
    • Network Device

In the next post, we will cover the remaining blocks of the YANG Suite workflow. We will learn how to build RPCs and execute them to extract information from network devices. So, stay tuned!!

Please feel free to provide your feedback/suggestions, if any.

Let’s connect on LinkedIn