The Rise of Network Automation
Automation is dramatically changing how Datacenter networks are managed. Here we will discuss how to manage your network using YANG models.
Models
NXOS has a comprehensive number of both native and open YANG models, that allow you to manage the rich feature-set that NXOS provides. Data models provide a structured and well-defined base that facilitates programmatic interaction with NXOS devices. The list of supported models includes native, OpenConfig and IETF models. In addition, YANG provides a modeling language optimized for network devices and with a growing number of tools and utilities. OpenConfig and IETF are vendor agnostic models, that abstract the detailed configuration across OSs and platforms.
Transports
NETCONF is a protocol defined by the IETF to “install, manipulate, and delete the configuration of network devices”. NETCONF operations are realized on top of a Remote Procedure Call (RPC) layer using an XML encoding and provides a basic set of operations to edit and query configuration on a network device.
RESTCONF is a REST like protocol running over HTTP for accessing data. It is an IETF draft that describes how to map a YANG specification to a RESTful interface. REST interfaces are based on the YANG data modeling language using NETCONF datastores.
Encodings
The separation of encodings from the choice of model and protocol provides additional flexibility. Encoding in both JSON and XML are supported, providing well understood formats in which the data can be structured.
The model driven programmability features in Cisco NXOS provide a flexible infrastructure for network automation. What makes it rich and flexible? The below diagram, gives a gives an indication of the wide variety and protocols, encoding and transports with which you can interact with NXOS.

There are many opensource tools with which we can automate the management on Nexus devices. Below are 3 differnet opensource tools, that that give you the power to automate your network in a programmatic manner.
- NCCLIENT - NCCLIENT is a Python library that facilitates client-side scripting and application development around the NETCONF protocol.
- PYANG PYANG is a YANG validator, and code generator, written in python.
- YDK YDK is an open source tool, developed by Cisco, to facilitate network programmability using data models. YDK can generate APIs in a variety of programming languages using YANG models.
To install these packages, simply enter the following command in a terminal
The Models
The following python script will allow us to see what we can configure on a Nexus 3000/9000
A snippet of the output shows that we can configure vlans using the OpenConfig model:
We have now established that we can configure vlans using OpenConfig YANG model, on a Nexus 3000/9000, but what is the format?
As the format can be quite verbose, we are going to utilize pyang and tree to reduce the output to an easily readable format. The will show all the user configurable fields (rw), the state values(ro) as well as the other models that it augments.
Using this we can now easily navigate the tree to help us build the required object. We want to be able to create these objects in a programmatic manner, and to be removed from the manually generating these objects. To achieve this we will use YDK.
The below script is all that is required to generate the object required to create a vlan. This can then be provisioned on the network in an automated manner. Here we are printing the object, just to show how using tools such as YDK have simplified the creation of such an object.
Output:
Conclusion
Using tools such as NCCLIENT or YDK this object can then be used to create the vlan on the network. The power of automation is that this is repeatable and scalable and can be be achieved for all models that are supported on NXOS. In this example, YDK generates the objects and ensures that all dependenices are met while removing us from the detailed syntax of the YANG model. Interacting with the network in this manner, enables you to manage your network in a more scalable and efficient manner.
Useful Links