Network Automation using YANG Models across XE, XR, & NX

YANG Development Kit (YDK)


Cisco's YANG Development Kit, or YDK for short, comprises a set of Python packages for analyzing, building, and interfacing with YANG models. YDK seeks to simplify the process of working with models so that users can rapidly get up and running with working Python code. In this section of the lab, we will use Cisco's YDK, Python, and YANG modules to configure our BGP topology.

The goal of this module is to put together all the building blocks that we've learned thus far, starting from an intial state with zero Python code, and ending in a final state with Python scripts that allow us to retrieve and perform configuration on our YANG-enabled devices.

In the following modules, we will use Python to import YDK packages that contain pre-built Python classes that map to Openconfig Models. Cisco's YDK contains thousands of Python classes mapping back to Openconfig, IETF, and Cisco native YANG modules. To learn more about YDK, check out their homepage.

Building on top of the foundations laid in the prior modules, we will continue to add new configuration to our existing XR, XE, and NX devices using Python and YDK. Each subsequent module in this section will have you leverage Python and the YANG concepts you have learned thus far and demonstrate some of the various ways models can be programmed while using Python to enable and configure BGP.


lab-topology-1


YDK-Python Exercises with OpenConfig

Although the BGP configuration steps in the subsequent sections all involve OpenConfig modules and Python, we configure each device using various techniques to demonstrate that there are many different practices that operators can normalize on with respect to day-to-day YANG development. You will get the chance to work through the following sections:

  • YDK-Python Intro: In this introduction to unifying these concepts, you will apply a simple BGP configuration to the XRv device and use YDK's CRUD instance to read the configuration you applied from the CLI, laying the foundations for the subsequent sections.

  • YDK-Python (XR): In this module, you will configure BGP on the XR router to align with the desired topology from our topology diagram. The OpenConfig BGP module will be used and you will apply the configuration using NETCONF via YDK as the transport mechanism for our YANG model data to the device.

  • YDK-Python (NX): Similar to the prior module, you will configure BGP on the NX router using YDK, NETCONF, and OpenConfig modules. A variation is added to demonstrate how one can manually specify YANG modules on a local filesystem, rather than having YDK automatically download the .yang files as it does by default.

Note: The XE device's BGP configuration will be done in the RESTCONF section using Python to drive RESTCONF data payloads containing OpenConfig YANG modeling data for BGP.