Describe
6.3 Describe the high-level principles and benefits of a data modeling language, such as YANG
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:
| Term | Meaning | Example |
|---|---|---|
| Module | A complete model file with a namespace | ietf-interfaces |
| Container | A group of related nodes | interfaces |
| List | A repeated set of entries with a key | interface with key name |
| Leaf | A single value with a type | enabled 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:
modulenames the model and gives it a namespace and prefix.container interfacesgroups the interface data.list interfacerepeats per interface.key "name"makesnamethe unique identifier.- Each
leafhas a type. The device rejects values outside the type. config falseonoper-statusmarks 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 enumerationRead the tree:
rwmeans read-write. This is configuration data.romeans 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:
| Kind | Mark | Meaning | Example |
|---|---|---|---|
| Configuration | rw | What you intend | enabled: true |
| State | ro | What the device observes | oper-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.
| Protocol | Transport | Encoding | Use |
|---|---|---|---|
| NETCONF | SSH, port 830 | XML | Full configuration operations: get, edit, lock, commit |
| RESTCONF | HTTPS | XML or JSON | HTTP 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:interfacesThe 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? booleanAnswer these questions:
- Name the container. (Answer:
ntp.) - Name the list and its key. (Answer: list
server, keyaddress.) - Name the leaves. (Answer:
addressandprefer.) - Which nodes are configuration? (Answer: all of them. Every node is
rw.) - Write a JSON payload with two servers:
10.10.10.5preferred and10.10.10.6not 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.
rwis configuration.rois operational state. A down interface can still haveenabled: 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
rwandromarks 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