Skip to content
Study CCNP

Describe

6.3 Describe the high-level principles and benefits of a data modeling language, such as YANG

4 min read ENCOR 350-401 v1.2 Updated

Aligned to Cisco's 350-401 ENCOR v1.2 exam topics.

On this page

What this objective tests

This is a describe objective. You must explain what YANG is and why it helps automation.

YANG is a data modeling language. YANG is not a protocol. Memorize that distinction.

A data model defines the shape of device data. It defines names, hierarchy, types, and allowed values. Without a model, scripts scrape CLI text and hope the format does not change. With a model, scripts read and write structured fields.

The building blocks

YANG models are trees. Know these four terms:

TermMeaningExample
ModuleA complete model file with a namespaceietf-interfaces
ContainerA group of related nodesinterfaces
ListA repeated set of entries with a keyinterface with key name
LeafA single value with a typeenabled of type boolean

A leaf-list is a repeated list of simple values. Example: a list of NTP server addresses.

Models come in three families:

  • IETF models: standards-based. Example: ietf-interfaces.
  • OpenConfig models: vendor-neutral, community-driven.
  • Native models: vendor-specific. Example: Cisco-IOS-XE-native. These expose every vendor feature but are less portable.

Example: a small YANG module

Read this excerpt. It models an interface:

module example-interfaces {
  namespace "urn:example:interfaces";
  prefix ex-if;

  container interfaces {
    list interface {
      key "name";

      leaf name {
        type string;
      }
      leaf description {
        type string;
      }
      leaf enabled {
        type boolean;
        default true;
      }
      leaf oper-status {
        type enumeration {
          enum up;
          enum down;
        }
        config false;
      }
    }
  }
}

Read it line by line:

  • module names the model and gives it a namespace and prefix.
  • container interfaces groups the interface data.
  • list interface repeats per interface. key "name" makes name the unique identifier.
  • Each leaf has a type. The device rejects values outside the type.
  • config false on oper-status marks it as read-only state. You cannot configure it.

The same model as a tree:

module: example-interfaces
  +--rw interfaces
     +--rw interface* [name]
        +--rw name            string
        +--rw description?    string
        +--rw enabled         boolean
        +--ro oper-status     enumeration

Read the tree:

  • rw means read-write. This is configuration data.
  • ro means read-only. This is operational state.
  • * means the list can repeat.
  • [name] is the list key.
  • ? means the node is optional.

Configuration versus state

This split is the most-tested YANG idea:

KindMarkMeaningExample
ConfigurationrwWhat you intendenabled: true
StateroWhat the device observesoper-status: down

These do not contradict each other. You can configure enabled: true. The interface can still show oper-status: down because the cable is unplugged.

How NETCONF and RESTCONF use YANG

YANG defines the data. The protocols move the data.

ProtocolTransportEncodingUse
NETCONFSSH, port 830XMLFull configuration operations: get, edit, lock, commit
RESTCONFHTTPSXML or JSONHTTP methods on YANG resources: GET, POST, PUT, PATCH, DELETE

A RESTCONF URL points at a YANG node:

https://10.10.10.11/restconf/data/ietf-interfaces:interfaces

The prefix before the colon is the module name. It tells client and device which model is in use. A matching JSON payload looks like this:

{
  "ietf-interfaces:interfaces": {
    "interface": [
      {
        "name": "GigabitEthernet1",
        "enabled": true
      }
    ]
  }
}

The payload keys mirror the model tree. Container, list, and leaf names all come from the YANG module.

Benefits of YANG

  • Predictable structure: the tool knows where every field lives.
  • Validation: types, ranges, and mandatory nodes reject bad data before it reaches the device.
  • Programmatic access: scripts parse structured data instead of scraping CLI text.
  • Multi-vendor support: IETF and OpenConfig models work across platforms.
  • Clear design: models force you to think in objects and state, not CLI lines.

Lab: read a tree and build a payload

This is a paper lab. Use this tree:

+--rw ntp
   +--rw server* [address]
      +--rw address    string
      +--rw prefer?    boolean

Answer these questions:

  1. Name the container. (Answer: ntp.)
  2. Name the list and its key. (Answer: list server, key address.)
  3. Name the leaves. (Answer: address and prefer.)
  4. Which nodes are configuration? (Answer: all of them. Every node is rw.)
  5. Write a JSON payload with two servers: 10.10.10.5 preferred and 10.10.10.6 not preferred. (Answer below.)

Expected payload:

{
  "ntp": {
    "server": [
      {
        "address": "10.10.10.5",
        "prefer": true
      },
      {
        "address": "10.10.10.6",
        "prefer": false
      }
    ]
  }
}

Exam traps

  • YANG is a modeling language. NETCONF and RESTCONF are protocols. Do not mix them.
  • rw is configuration. ro is operational state. A down interface can still have enabled: true.
  • Lists have keys. Containers do not repeat.
  • Native models expose all features but are vendor-specific. Standard models trade features for portability.

Pass check

You are ready when you can do these things:

  • Explain what a data model is in one sentence.
  • Identify module, container, list, key, and leaf in a YANG excerpt.
  • Read rw and ro marks in a model tree.
  • Map a model tree to a JSON payload.
  • Name the transport and encoding of NETCONF and RESTCONF.

Sources used

  • Cisco ENCOR 350-401 v1.2 exam topics: https://learningcontent.cisco.com/documents/marketing/exam-topics/350-401-ENCORE-v1.2.pdf
  • Cisco IOS XE Programmability Configuration Guide, YANG/NETCONF: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/1715/b_1715_programmability_cg/m_1715_prog_yang_netconf.html

Related objectives