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

Try it free for 30 minutesRun it on Lite from £3 a day

The free demo needs no card and no email. Every lab plan includes every guided lab.

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.

ItemValue
xe110.10.20.21, NETCONF 830, RESTCONF 443, login netops / NetOps-Lab1
To buildLoopback101 10.255.101.1/32 "Built from the YANG tree (XML)" · Loopback102 10.255.102.1/32 "Built from the YANG tree (JSON)"
Filestrees/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

  1. YANG in ten minutes
  2. Which models does xe1 support?
  3. Download the modules themselves
  4. Read the tree like the exam does
  5. Build an XML payload from the tree (NETCONF)
  6. Build a JSON payload from the tree (RESTCONF)
  7. Let the device validate you
  8. 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.

Topology of YANG models - read modules and trees then build XML and JSON payloads2 nodes and 1 network, 2 links. Every link is listed as text below the diagram.devboxxe1Mgmteth0Gi1
2 nodes and 1 network, with the interface names each link uses. On a narrow screen, scroll the diagram sideways.
Nodes in YANG models: read modules and trees, then build XML and JSON payloads, with the image each runs and the vCPU and RAM it’s set to
NodeDeviceImage in Add NodeSet to
devboxEVE-NG GUI server (Docker)eve-gui-server:latest1 vCPU, 1,024 MB
xe1Cisco CSR 1000vcsr1000vng-universalk9.17.03.08a-serial1 vCPU, 4,096 MB

How to open this lab

  1. Sign in to your workspace at lab.cloudlabbox.com.

  2. In File Manager, open Shared, then the folder Network Automation - CCNA and CCNP Automation guided labs.

  3. Open 08 - YANG models - read modules and trees then build XML and JSON payloads and 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

All 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.