Use it to find the exact path and data format for an API call, or when a device rejects a payload as invalid.
YANG Models
1. Which model covers the data (native, IETF, OpenConfig)?
2. pyang -f tree — the path from the top container to the leaf.
3. Device supports that model and revision?
4. Payload matches types and keys (e.g. interface name as list key)?
5. Read it back with GET / get-config.
model chosen → path through containers and lists → keys and types respected → device supports the model → request accepted → data reads back
The device rejects data with an unknown element, wrong namespace or missing key.
Possible stored cause: The module, namespace or list key in the payload does not match the model the device implements.Context & applicabilityCommon mistakes · platform/version boundaries
The most important misconception is show ip route = forwarding works. A route can exist while recursive resolution, neighbor resolution or the outgoing adjacency remains unusable.
Local intent: Hierarchical containers, lists, leaves, types and constraints that describe network configuration/state data.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
The device rejects data with an unknown element, wrong namespace or missing key.
Step 1 Verification & evidence Verify boundary
Trace a YANG path into JSON/XML representation and identify list keys/leaves.
Step 2 Common failure modes Narrow the fault
Wrong module/namespace/path, confusing schema with instance data or ignoring list keys/types.
Step 3 Troubleshooting workflow Narrow the fault
Focus for this topic: Wrong module/namespace/path, confusing schema with instance data or ignoring list keys/types.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Models are native (Cisco-IOS-XE-*), IETF (ietf-interfaces) or OpenConfig. A list is indexed by its key leaf (e.g. interface name). config false nodes are read-only state. Use pyang or the YANG Suite to browse a model: pyang -f tree <model>.yang.
pyang -f tree <model>.yang— the model as a readable tree.- Cisco YANG Suite — browse models from the device and build requests.
- NETCONF capabilities / RESTCONF
/restconf/data/ietf-yang-library:modules-state— models and revisions the device supports. - GitHub YangModels/yang — published models per release.
ReferenceWhat it is1 section · depth on demand
ReferenceHow it works1 section · depth on demand
How it works
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Reading and using YANG models
YANG describes what data a device accepts and reports. Being able to read a model is the key to writing NETCONF, RESTCONF or gNMI requests. RFC 7950 defines the building blocks:
- Modules: each has a namespace, a prefix and revisions.
- Containers: group child nodes; a container exists at most once.
- Lists: have several instances, identified by key leafs.
- Leafs and leaf-lists: hold a value, or a set of values.
- Choice and case: alternatives, only one of which can be valid at a time.
- Grouping, uses and augment: reuse groups of nodes and extend other models.
config false: marks state data, as opposed to configuration.- rpc, action and notification: operations and events.
Node types and their data form
| YANG | JSON representation | Example |
|---|---|---|
| container | Object | "interfaces": { ... } |
| list (key "name") | Array of objects | "interface": [ {"name": "Gi1/0/14", ...} ] |
| leaf | Value | "enabled": true |
| leaf-list | Array of values | "vlans": [110, 120] |
| choice/case | Only one branch appears | Never shown itself |
Model families
| Family | Scope |
|---|---|
IETF (ietf-interfaces, ietf-ip) | Vendor-neutral, limited feature coverage |
| OpenConfig | Operator-driven, vendor-neutral, broader |
Native (Cisco-IOS-XE-native) | The full platform feature set |
| Deviations | What a platform doesn't implement as modelled |
A tree view
dev$ pyang -f tree ietf-interfaces.yang | head -14
module: ietf-interfaces
+--rw interfaces
| +--rw interface* [name]
| +--rw name string
| +--rw description? string
| +--rw type identityref
| +--rw enabled? boolean
| +--ro oper-status enumeration
| +--ro statistics
| +--ro in-octets? yang:counter64
dev$ curl -sk -u netadmin:'<password>' "https://10.255.1.21/restconf/data/ietf-yang-library:modules-state" | jq -r '.["ietf-yang-library:modules-state"].module[].name' | grep -c .
Reading the tree
| Symbol | Meaning |
|---|---|
rw / ro | Configuration / state (config false) |
* after a name | List, with the key in brackets |
? | Optional leaf |
No ? on an rw leaf | Mandatory |
Always check a platform's deviations before relying on a model. A leaf in the standard model may be marked "not supported" on the device.
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation and Artificial Intelligence → YANG Models. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc7950.html · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Model-driven network configuration protocol using RPC/datastore semantics.
Automation · relatedRESTCONFRESTCONF exposes YANG-modeled network data using HTTP resources and methods.
Routing · relatedRIBRouting Information Base: the routing table of routes selected for installation.
Automation · relatedYANGYANG is a data modeling language that defines structured configuration and operational data, including hierarchy, types, constraints and reusable modules.
Deep reference
Design & tradeoffs
ENCOR design tradeoffs
Models enable consistent automation across tools, but vendor/platform augmentations still matter.