Skip to content

Network Automation

My journey with Network & Cloud Automation

Menu
  • Beginner
  • DevOps-NetDevOps
  • Network Automation
    • Docker
    • Python Libraries
      • NAPALM
      • Netmiko
      • Jinja2
      • Scrapli
      • Yang
  • Cloud Automation
    • Terraform
  • Python 🐍 Tips and Tricks
Menu
yang for network engineers

What is YANG For Network Engineers

Posted on August 25, 2021August 24, 2021 by Gurpreet Kochar

As network engineers are bombarded with more and more terms like NETCONF, RESTCONF, YANG, REST APIs every day, it’s becoming increasingly important to understand the basics of these terms if not in-depth for all network engineers. To begin this series of uncovering the meaning and relevance of these terms for network engineers, let’s start by demystifying What is YANG For Network Engineers.

YANG is a data modeling language and it stands for Yet Another Next Generation. Now the very immediate question is What does data modeling language mean?

Think of YANG as an architectural blueprint where the architect clearly mentions the overall view and tiny details like dimensions and types of individual building blocks. Think of YANG like classes in Object Oriented Programming languages. Let’s try to take an example that is closer to the field of network engineering.

The YANG model defines how the CLI of the devices will behave. So for a device that supports NETCONF, it will also support a YANG model which essentially means, if two devices are based on same YANG model, they will have similar CLI fields and expected fields in the command outputs.

Think of YANG data model as SNMP MIB so if devices of multiple vendors support same MIBs, you can safely predict the response and behaviour of that device via monitoring tools.

https://github.com/YangModels/yang/tree/master/vendor/cisco/xe/1761

Let’s take a look at the CISCO YANG model for the operational state data of BGP.

This YANG model above defines

  1. What you see in cisco CLI for BGP operational state
  2. When you hit ?, the autocomplete options that you see are modelled after this datamodel.
  3. The validation errors that you get when you type unexpected value is also due to the parameters that are coded in the above YANG model. Take a look at this small excerpt from this huge yang model.
leaf as {
  type uint32;
  description
    "BGP neighbor AS number";
  }
leaf local-port {
  type uint32;
  description
  "Local TCP port used for TCP session";
  }
leaf local-host {
  type inet:ip-address;
  description
  "Local address used for the TCP session";
  }
leaf foreign-port {
  type uint32;
  description
  "Remote port used by the peer for the TCP session";
  }
leaf foreign-host {
  type inet:ip-address;
  description
  "Remote address of the BGP session";
  }

If you look closely, it clearly specifies that the AS number is of type uint32 ( unsigned integer 32 bytes ) which in other means you can’t put a string there, it has to be a number otherwise the CLI will throw an error. Similarly, you can’t put any random number in the local-host field, it has to comply with the ip-address data format. So if you put anything that is not an ip address, you would have noticed CLI throughs an error. All these are validated by YANG DataModels for the devices that support YANG Models. Older CLI devices did not use YANG but pure programming logic to achieve this.

YANG Resources:-

  1. Cisco’s YangSuite
  2. Github repo
  3. Juniper Github
  4. Openconfig Yang Github
  5. YangValidator Website

Know someone who may benefit? Share this:

  • Tweet
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email
  • More
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Share on Tumblr
  • Pocket

Like this:

Like Loading...

Related

Leave a ReplyCancel reply

All Blog Posts
My Resume

Upcoming Posts

Sorry - nothing planned yet!

Recent Posts

  • How to backup configuration to TFTP Server using Ansible – Part II
  • How to backup network devices using Ansible – Part I
  • Netmiko SSH Proxy/JumpServer
  • A short note on SASE
  • Understanding Ansible

Recent Comments

  1. Jack on Multithreading with Python for Network Engineers
  2. LifeCanvas on [Theory] Multithreading vs Multiprocessing vs AsyncIO
  3. Jasper Horng on Netmiko SSH Proxy/JumpServer
  4. asdfasdf on Python API Using FASTAPI – UPDATE – PUT – PATCH – Part V
  5. Gurpreet Kochar on Python Scrapli AsyncIO Usage

Archives

  • September 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
Topic Request / Suggestion
Loading
© 2025 Network Automation | Powered by Minimalist Blog WordPress Theme
 

Loading Comments...
 

    %d