• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Rowell Dionicio

Get Techie With It

  • Home
  • About
  • Resources
    • Archives
    • Book List
    • YouTube
  • Learn
    • DevNet Associate
    • PCNSA Certified
  • Blog
  • Contact
  • Show Search
Hide Search

What is YANG – For Network Engineers

October 29, 2019 By Rowell Leave a Comment

YANG – Yet Another Next Generation. Network engineers are used to hearing Next Generation. For example, Next Generation Firewalls and Next Generation Wireless.

But in this case, I’m talking about a data modeling language. It’s used with something like NETCONF and RESTCONF. YANG is used to describe networking data models and defines a structure.

YANG was developed by the IETF. Read RFC 6020 to get all the details of how it works. API requests use NETCONF or RESTCONF to make configuration changes and review the configuration.

Building blocks of YANG

  • module – top of the hierarchy of nodes
  • containers – related nodes
  • lists – identifies nodes
  • leaf – individual attributes of a node
  • type – every leaf has an associated type

Here’s an example:

  • Employee
    • Employee ID
    • SSN
    • Gender
    • Address
    • Birthday

A data model could be about a network device or service. A network device will have containers and leafs about its interfaces, statistics, VLANs, etc. A YANG model on a service may be ACLS, VRFs, BGP, etc.

To explore the YANG models pyang can be used. Pyang will validate and convert YANG modules to different formats.

I’m going to be using using my DevNet lab files to look into pyang further.

We’ll explore a file on my desktop, ietf-interfaces.yang. If you’re going through the DevNet classes then you will also learn about YANG. Some of the examples are taken from DevNet.

YANG Model

To view the the YANG model, I’m going to issue a command in iTerm2, pyang, to display the tree.

I was able to get a copy of the YANG model from the DevNet labs. In one lab I used git to download a whole folder of YANG models. On my computer I use pyang to view details of those YANG models.

Taking a look at ietf-interfaces.yang, there are two containers, created called interfaces and interfaces-state.

ietf-interfacesis a module of the container. Inside a container is a list. Within the list is the leaf, which are attributes of the individual node items.

You may notice there are rw and ro in front of the name.

rw = read/write
ro = read-only

In the example below, ietf-interfaces is the module. interfaces will be the container, consisting of interface leaf with attributes such as the interface name, description, and type.

To the right of the leaf describes what type of attribute it is.

$ pyang -f tree ietf-interfaces.yang
module: ietf-interfaces
  +--rw interfaces
  |  +--rw interface* [name]
  |     +--rw name                        string
  |     +--rw description?                string
  |     +--rw type                        identityref
  |     +--rw enabled?                    boolean
  |     +--rw link-up-down-trap-enable?   enumeration {if-mib}?
  |     +--ro admin-status                enumeration {if-mib}?
  |     +--ro oper-status                 enumeration
  |     +--ro last-change?                yang:date-and-time
  |     +--ro if-index                    int32 {if-mib}?
  |     +--ro phys-address?               yang:phys-address
  |     +--ro higher-layer-if*            interface-ref
  |     +--ro lower-layer-if*             interface-ref
  |     +--ro speed?                      yang:gauge64
  |     +--ro statistics
  |        +--ro discontinuity-time    yang:date-and-time
  |        +--ro in-octets?            yang:counter64
  |        +--ro in-unicast-pkts?      yang:counter64
  |        +--ro in-broadcast-pkts?    yang:counter64
  |        +--ro in-multicast-pkts?    yang:counter64
  |        +--ro in-discards?          yang:counter32
  |        +--ro in-errors?            yang:counter32
  |        +--ro in-unknown-protos?    yang:counter32
  |        +--ro out-octets?           yang:counter64
  |        +--ro out-unicast-pkts?     yang:counter64
  |        +--ro out-broadcast-pkts?   yang:counter64
  |        +--ro out-multicast-pkts?   yang:counter64
  |        +--ro out-discards?         yang:counter32
  |        +--ro out-errors?           yang:counter32
  x--ro interfaces-state
     x--ro interface* [name]
        x--ro name               string
        x--ro type               identityref
        x--ro admin-status       enumeration {if-mib}?
        x--ro oper-status        enumeration
        x--ro last-change?       yang:date-and-time
        x--ro if-index           int32 {if-mib}?
        x--ro phys-address?      yang:phys-address
        x--ro higher-layer-if*   interface-state-ref
        x--ro lower-layer-if*    interface-state-ref
        x--ro speed?             yang:gauge64
        x--ro statistics
           x--ro discontinuity-time    yang:date-and-time
           x--ro in-octets?            yang:counter64
           x--ro in-unicast-pkts?      yang:counter64
           x--ro in-broadcast-pkts?    yang:counter64
           x--ro in-multicast-pkts?    yang:counter64
           x--ro in-discards?          yang:counter32
           x--ro in-errors?            yang:counter32
           x--ro in-unknown-protos?    yang:counter32
           x--ro out-octets?           yang:counter64
           x--ro out-unicast-pkts?     yang:counter64
           x--ro out-broadcast-pkts?   yang:counter64
           x--ro out-multicast-pkts?   yang:counter64
           x--ro out-discards?         yang:counter32
           x--ro out-errors?           yang:counter32

Share this:

  • Facebook
  • LinkedIn
  • Twitter

Related

Filed Under: Coding, DevNet Associate Tagged With: devasc, devnet associate, yang

About Rowell

Wi-Fi expert. Coffee addict ☕️. Tech nerd. Business owner.

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • Passed Palo Alto Networks Certified Security Administrator (PCNSA)
  • 5 Years Running
  • Q4 2021 and Yearly Income Report
  • I PASSED JNCIA-MistAI
  • Admins and Role-Based Access Control – PCNSA

Categories

  • bschool
  • Certifications
  • Coding
  • DevNet Associate
  • Events
  • Lab
  • Networking
  • Personal
  • Podcasting
  • Professional
  • Reviews
  • Security
  • Short Stories
  • Uncategorized
  • Wireless

Archives

  • May 2022
  • January 2022
  • December 2021
  • November 2021
  • August 2021
  • July 2021
  • April 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • November 2018
  • September 2018
  • August 2018

Copyright © 2022 · Written by Rowell Dionicio · You're awesome.

 

Loading Comments...