YANG based Network Automation using NETCONF RESTCONF gNMI


YANG-based network automation uses a YANG hierarchical data structure that is natively structured, and therefore provides the capability to programmatically configure and also monitor network devices.

In other words, in YANG based network automation, we do not send CLI commands anymore but we update or read the data inside YANG data structure.

– With the purchase of this course, the first part of the videos can be downloaded immediately. The second part of the videos will be processed exclusively for you and will take 2 working days.
– You will also get access to the protected lessons of the purchased course.


YANG based Network Automation using NETCONF RESTCONF gNMI
NETCONF, RESTCONF and gNMI Introduction
YANG based network automation using NETCONF, RESTCONF and gNMI protocols are the discussion of this course.
In the first lesson of the course, we will have a review and compare these three protocols.
Network automation protocols such as NETCONF, RESTCONF, gNMI, and Ansible use XML, JSON,, YAML or Protobuf data structures as a common language for data exchange between network devices and automation controller.
In this section we will have a practical overview and comparison between XML, JSON and YAML data formats or structures. Protobuf will be discussed in gNMI section.
YANG is a data model language used by NETCONF, RESTCONF, and gNMI to automate network configuration, maintenance, and troubleshooting.
However, before we use YANG with various automation protocols throughout the course, in this section we will review and explore the YANG data model to better understand it.
Network Automation using NETCONF
NETCONF is one of the YANG-based network automation protocols that we will use throughout the course.
In this section we will discuss the fundamental concepts of the NETCONF protocol before moving on to the demonstration that starts in the next section.
netconf get-config is a Yang-based method to get configuration of network devices via netconf protocol.
Besides getting the configuration, the other application of using netconf get-config is to find the appropriate YANG model for each part of the configuration.
netconf xpath is one type of filter that gives the capability to limit the output of “show commands” to a specific part of the configuration or statistics.
To filter the output, you need to specify the exact path of interesting configurations or statistics in the corresponding Yang model.
Subtree is another filter type that will be discussed in the next sections
netconf xpath filter example for get command is the topic of this section.
In the previous section, we used xpath filter for the netconf get-config command, which is used to get the configuration of network devices.
However, the netconf get command is mainly used to get the statistics of network devices.
With xpath filter it is also possible to filter the statistics in order to show only a certain section in the output.
netconf subtree filter is the second filter method to limit the output of configuration or statistics to only show interesting section.
Subtree filters must be supported by every netconf implementation, but xpath filters, discussed in the previous section, may not be supported.
When we get the configuration or statistics through netconf protocol, the format of output is XML and to be able to access and process any section of the output, we need to convert the XML to the dictionary format.
Using “xmltodict” in netconf gives the capability to access and process any section of the netconf xml output in the python code.
netconf edit-config gives us the capability to change the configuration of network devices.
The idea of changing the configuration of network devices via “netconf edit-config” is simple.
Get the interesting part of the configuration with the Netconf protocol, which is in the format of XML. Change the configuration in the XML subtree and upload it again to the device.
There are two types of configuration changes, “merge” and “replace“, which are also covered in this section
Jinja2 Template in netconf help us separate network device configurations from automation script.
Jinja2 Template is a common configuration template for many network devices, in which in its simplest form, data from network devices are replaced with variables.
When applying the configuration template to network devices, variables in the configuration template are replaced with data of each network device.
Network Automation using RESTCONF
What is restconf in network automation? This is the question we will begin to answer in this section and demonstrate in the next few sections.
Restconf is another network automation method that allows us to monitor the configuration and statistics of network devices and also change or delete the configuration.
This section is dedicated to the basic concept of the restconf protocol.
In the previous section, we used the curl tool to communicate with network devices using the restconf protocol. In this section, we use postman to monitor and configure network devices via the restconf protocol. in other words, restconf with postman
restconf request with python request:
Starting in this section, we will receive and send configuration to and from network devices using the restconf protocol implemented with Python scripts.
In this section we will use a simple Python “request” library to communicate with network devices, but from the next section we will use the inventory management and multi-threading capability of the Python Nornir plugin.
In the previous section we used python request library to send restconf requests to network devices and get a part of running configuration.
In this section we will use python nornir plugin beside the request plugin, which adds inventory management and multithreading capability into restconf requests.
Therefore, we do not need to add the list of devices and their credentials inside automation script since the inventory is maintained in different set of files in the nornir plugin.
The automation script is also run on multiple devices at the same time, which is different from Python request plugin, which runs the automation script on network devices one at a time.
In the previous section we have demonstrated to get the configuration using restconf and nornir python libraries.
To get the configuration, we use http get command but to change the configuration there are three options, http post, put and patch commands.
In this section we will change the configuration using these commands and we will see the difference between http put, post and patch commands.
we will also demonstrate how delete the configuration using http delete command.
In the previous sections we have configured network devices using json payload sent through requests python library in restconf protocol.
But probably the easiest way to keep the configuration data is in yaml format. Then the Python “load_yaml” from “nornir utils” library has the option to automatically change yaml to json before sending it to the network devices.
This is what we are going to demonstrate in this section.
In this section, we use jinja2 template in restconf protocol to edit the configuration of network devices.
However, we will not use jinja2 template features like variable substitution, conditional and looping. We will use jnja2 template just to separate the configuration from the automation script.
In this section we will configure network devices using restconf protocol but through json based jinja2 configuration template and yaml based configuration data.
Network Automation using gRPC/gNMI
gRPC / gNMI is the latest Yang-based network automation method that is the topic of this module.
In this section, we introduce gRPC and gNMI and compare it to the RESTCONF and NETCONF protocols, the other two Yang-based network automation methods that we discussed in the previous modules.
Arista gNMI Lab preparation is the topic this section since it easier and more accessible to prepare gNMI with cisco devices.
We will load Arista vEOS into the VMware workstation and perform the initial configuration to connect to the device. Also, we will enable gNMI for our next demonstrations.
gNMI get with gnmic is the topic of this section. In other words, we will use gnmi client tool to get specific section of the configuration from network devices.
Finding the path in the YANG data model is actually the most difficult task to get or update the configuration of network devices.
With gnmi client interactive mode, it is easier to find the path to each part of the configuration.
We will use gnmi set command to create, update or delete the configuration of network devices.
We will update the new configuration through gnmic set commands in this section but it will be done using python gnmi library in the next sections.
gnmi streaming with subscribe command is the most important feature of gnmi protocol, at least nowadays that netconf and restconf are the main yang based automation protocols.
In this section, you will learn how to subscribe to any data in the yang data model using gnmic to stream it to the subscriber on changes or at intervals.
Python gnmi client library, pygnmi, is another method of network automation over the gnmi protocol which is the subject of this section and the coming sections.
In this section we will use pygnmi, python gnmi client library, to send “set”, “delete” and “subscribe” commands to network devices.
The gnmi commands “capabilities” and “get” are discussed in the previous section.


There are no reviews yet.

Be the first to review “YANG based Network Automation using NETCONF RESTCONF gNMI”

Your email address will not be published. Required fields are marked *

Post comment