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

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; }
    }
  }
}
StatementMeaningIn JSON
containerA group of nodesAn object
list (key)Repeated entries identified by a keyAn array of objects
leafA single typed valueA value
leaf-listA list of valuesAn array of values
type, range, defaultValidation rulesEnforced 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

SourceScope
IETFStandard models for common features (interfaces, IP, routing)
OpenConfigOperator-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.yangShows a model as a tree.
show netconf-yang datastoresDatastores the device supports.
NETCONF helloLists every model (capability) the device supports.

Exam traps

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.

More topics in 6.0 Automation and Artificial Intelligence