Yet Another Next Generation YANG is a data modeling language that the IETF defined in 2010 in RFC 6020.

YANG is the most common data model language for protocols like NETCONF, RESTCONF, and gNMI.
YANG is a standardized data modeling language that was in part created out of the necessity for a standardized data model for protocols like NETCONF.

This overview highlights some popular tools that provide a good learning path for YANG: pyang, ydk, yang validator, and YANG suite.

Pyang is a Python tool that offers YANG validation features and various YANG translation and conversion operations. Pyang can be helpful in generating tree representations of YANG models or generating Unified Modeling Language (UML) diagrams from YANG models.

As an extension of pyang, the PyangBind add-on allows developers to create usable Python classes from source YANG data models. Based on source YANG models, this tool can programmatically generate usable Python classes to interact with those models.

The Yang Development Kit (YDK) is a software development kit that provides APIs that are modeled in YANG. The YDK is an open source and freely available collection of code that is designed to make developing network automation scripts and applications easier by reducing the learning curve of YANG data models and abstracting protocol and encoding details.

The YANG validator is a website that allows you to fetch, extract, and validate YANG modules, either by RFC number, by IETF draft name, or by uploading YANG files. It is built in addition to the pyang, confdc, and yanglint YANG compilers to validate the extracted modules.

YANG Suite is an interactive YANG exploration tool that includes a YANG browser, an RPC builder, and a script generator to experiment with YANG modules. YANG Suite allows you to manage YANG model files, explore YANG models, and make NETCONF requests.

Finally, one more tool to be aware of is Yangson. Yangson is a Python 3 library for working with JSON encoded configuration and state data that is modeled using the YANG data modeling language. Yangson allows for data instance validation, editing the data tree, and supports RESTCONF data resources and resource identifiers as well as NETCONF Access Control Module (NACM).

YANG uses a series of statements as the building blocks of the language

  • Leaf
  • Leaf list
  • List
  • Container
leaf hostname {
    type string; 
    mandatory true; 
    config true; 
    description "Hostname for the network device"; 
}

Because YANG is only used to model the data or define the structure, you can present data in XML and JSON data formats:

<hostname>NYC-R1</hostname>
{
    "hostname": "NYC-R1" 
}

Leaf List

leaf-list vlans {
    type uint16 { 
        tailf:info "WORD;;VLAN IDs of the allowed VLANs when this port is in trunking mode"; 
    } 
}
<vlans>10</vlans>
<vlans>20</vlans>
<vlans>30</vlans>
{
    "vlans": [ 
        10, 
        20, 
        30 
    ] 
}

<
Previous Post
NETCONF
>
Next Post
Linux Summary