Network automation lab 8 of 27
YANG models: read modules and trees, then build XML and JSON payloads
Learn to read YANG the way the exam and real work need: find which models a router supports, download the modules themselves, read an RFC 8340 tree, then build XML and JSON payloads from the tree alone and let the device validate them, and compare the IETF, Cisco native and OpenConfig views of one interface.
Run this lab
It needs Lite: its 2 nodes are set to 2 vCPU and 5,120 MB in total. That fits the free demo too.
In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 08 - YANG models - read modules and trees then build XML and JSON payloads
- Level
- Intermediate
- Time
- About 75 minutes
- Nodes need
- 2 vCPU, 5,120 MB
- Smallest plan
- Lite
The scenario
Kestrel Freight's developers keep asking the network team the same question: "what exactly do I send to the router?" The answer is always in a YANG model. Today you'll become the person who can answer it: find which models the IOS XE router xe1 supports, read the standard interface models the way the exam presents them (as trees), and build two loopbacks purely from those trees, one with an XML payload over NETCONF and one with a JSON payload over RESTCONF, letting the router's own validation tell you when you get it wrong.
| Item | Value |
|---|---|
| xe1 | 10.10.20.21, NETCONF 830, RESTCONF 443, login netops / NetOps-Lab1 |
| To build | Loopback101 10.255.101.1/32 "Built from the YANG tree (XML)" · Loopback102 10.255.102.1/32 "Built from the YANG tree (JSON)" |
| Files | trees/ietf-interfaces.tree, trees/ietf-ip.tree (pyang output for the revisions xe1 serves), push.py (sends a payload and prints the device's answer), empty payloads/ and yang/ |
What you’ll practise
- Explain YANG building blocks: module, namespace, prefix, container, list and key, leaf, leaf-list, type, identity, choice, augment, config and state
- Discover a device's YANG modules from NETCONF capabilities and download them with get-schema
- Interpret a YANG tree in RFC 8340 format, including rw/ro, ?, *, !, choices and features
- Construct XML (NETCONF) and JSON (RESTCONF) payloads from a tree and correct them from the device's validation errors
- Compare IETF, OpenConfig and native models and choose between them
The tasks
- YANG in ten minutes
- Which models does xe1 support?
- Download the modules themselves
- Read the tree like the exam does
- Build an XML payload from the tree (NETCONF)
- Build a JSON payload from the tree (RESTCONF)
- Let the device validate you
- Three models, one interface
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- devbox
eth0to Mgmt (network) - xe1
Gi1to Mgmt (network)
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| xe1 | Cisco CSR 1000v | csr1000vng-universalk9.17.03.08a-serial | 1 vCPU, 4,096 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation - CCNA and CCNP Automation guided labs.Open
08 - YANG models - read modules and trees then build XML and JSON payloadsand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Network automation labs
Related labs in other courses
CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.