6.3 Describe what a data modeling language such as YANG offers
ENCOR 350-401 v1.2 · 6.0 Automation and Artificial Intelligence
YANG is a language for describing what can be configured and monitored on a device: the structure, the types and the rules. NETCONF and RESTCONF carry data that follows YANG models, so a script knows exactly what to send. ENCOR expects you to say what YANG offers and read a small model.
What you must know
- Explain why data models matter: structure, types, validation, vendor neutrality.
- Read YANG building blocks: module, container, list (with key), leaf, leaf-list, type.
- Compare model sources: IETF, OpenConfig, Cisco native.
- Map a YANG path to a RESTCONF URI or a NETCONF filter.
A small model
module example-vlans {
namespace "urn:example:vlans";
prefix ev;
container vlans {
list vlan {
key "id";
leaf id { type uint16 { range "1..4094"; } }
leaf name { type string; }
leaf active { type boolean; default true; }
}
}
}| Statement | Meaning | In JSON |
|---|---|---|
| container | A group of nodes | An object |
| list (key) | Repeated entries identified by a key | An array of objects |
| leaf | A single typed value | A value |
| leaf-list | A list of values | An array of values |
| type, range, default | Validation rules | Enforced by the device |
Because the model says id is 1–4094, the device rejects VLAN 5000 before touching the configuration. That is the main gain over screen-scraping CLI: the data is structured, typed and validated.
The RESTCONF URI is the model's path: module, container, list and key (1). A NETCONF <get-config> filter uses the same path as XML.
Where models come from
| Source | Scope |
|---|---|
| IETF | Standard models for common features (interfaces, IP, routing) |
| OpenConfig | Operator-written, vendor-neutral models, strong for telemetry |
| Cisco native (Cisco-IOS-XE-native) | Covers every IOS XE feature, mirrors the CLI |
Models are published on GitHub (YangModels/yang) and listed by the device in its NETCONF hello. Tools such as pyang or YANG Suite show a model as a tree.
Commands
pyang -f tree model.yang | Shows a model as a tree. |
show netconf-yang datastores | Datastores the device supports. |
NETCONF hello | Lists every model (capability) the device supports. |
Exam traps
- YANG describes data; NETCONF and RESTCONF transport it.
- A list needs a key; a container does not.
- The device validates types and ranges from the model.
- Native models cover everything; IETF and OpenConfig are portable.
Check yourself
- Which YANG statement defines repeated entries identified by a key?
- list.
- What is a leaf?
- A single typed value, such as a VLAN name.
- Why are OpenConfig models popular with operators?
- They are vendor-neutral, so one script works across vendors.