Test your knowledge on this topic in the ENAUTO Exam Trainer — 186 questions across 5 interactive modes.
Network Automation Foundation — Deep Dive for ENAUTO v2.0
Exam Relevance
Topic 1.0 Network Automation Foundation (10%) provides the conceptual backbone for all device-level automation in Topics 2.0 and 4.0. Mastering YANG, NETCONF, and RESTCONF here unlocks every controller API and device-level script in the rest of the exam.
Exam Topics Covered:
1.1 – Compare data models (IETF, OpenConfig, native)
1.2 – Describe NETCONF and RESTCONF
1.3 – Describe YANG Suite and pyang
1.4 – Construct JSON/XML payloads from YANG models
1.5 – Interpret a YANG module tree diagram (RFC 8340)
YANG (Yet Another Next Generation) is a data modeling language defined in RFC 7950. It does not carry data itself — it defines the structure, constraints, and semantics of configuration and operational data that protocols like NETCONF and RESTCONF transport.
Think of YANG as the schema (like a database DDL) while NETCONF/RESTCONF are the query languages (like SQL).
┌───────────────────────────────────────────┐
│ YANG Model │
│ (defines what data looks like) │
│ RFC 7950 │
└──────────────┬────────────────────────────┘
│ describes structure for
┌───────┴───────┐
▼ ▼
┌─────────────┐ ┌─────────────┐
│ NETCONF │ │ RESTCONF │
│ RFC 6241 │ │ RFC 8040 │
│ XML │ │ JSON / XML │
│ SSH :830 │ │ HTTPS :443 │
└─────────────┘ └─────────────┘
Key YANG Concepts
Concept
Description
Example
module
Top-level unit; one model = one module
module ietf-interfaces
container
Grouping node (like a folder) — maps to JSON object / XML element
container interfaces
list
Ordered collection with a key — maps to JSON array
list interface with key "name"
leaf
Single scalar value — maps to JSON key-value
leaf name { type string; }
leaf-list
Array of scalar values
leaf-list dns-server { type inet:ipv4-address; }
choice
Mutually exclusive branches
choice address-type { case ipv4 {...} case ipv6 {...} }
augment
Extend another module’s tree
ietf-ip augments ietf-interfaces
deviation
Vendor declares “I implement this differently”
Device does not support a leaf
grouping
Reusable set of nodes (like a macro)
grouping address-family { ... }
typedef
Custom type definition
typedef percent { type uint8 { range "0..100"; } }
Exam Tip
augmentadds nodes to another module’s tree. deviationmodifies or removes nodes a vendor cannot support. Both are commonly tested.
Three Families of YANG Models
IETF Models (Standards-Track)
Defined by IETF working groups, published as RFCs
Namespace: urn:ietf:params:xml:ns:yang:*
Vendor-neutral, widely supported across platforms
Narrow scope — one model per feature (interfaces, routing, ACLs)
The candidate datastore lets you stage changes and validate them before committing. Not all devices support it — check the <hello> capabilities exchange for :candidate.
GET /restconf/data/ietf-interfaces:interfaces
GET /restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1
GET /restconf/data/Cisco-IOS-XE-native:native/interface/Loopback=100
HTTP Method Mapping
HTTP Method
RESTCONF Operation
NETCONF Equivalent
GET
Read data
<get> / <get-config>
POST
Create new resource
<edit-config> (operation=“create”)
PUT
Create or replace resource
<edit-config> (operation=“replace”)
PATCH
Merge/update resource
<edit-config> (operation=“merge”)
DELETE
Remove resource
<edit-config> (operation=“delete”)
POST vs PUT vs PATCH
POST = create only, fails if resource exists (409 Conflict)
PUT = create or replace entire resource
PATCH = merge changes into existing resource (safest for updates)
The exam frequently tests this distinction.
Content-Type Headers
Format
Content-Type
Accept
JSON
application/yang-data+json
application/yang-data+json
XML
application/yang-data+xml
application/yang-data+xml
Discovery
RESTCONF root is discovered via /.well-known/host-meta:
NETCONF when you need candidate config, locking, or atomic multi-device transactions
RESTCONF when you want JSON, quick integrations, or already have HTTP tooling
Both use the same YANG models — the payload structure is identical, just different encoding
3 – YANG Suite and pyang (Exam Topics 1.3, 1.4)
YANG Suite
YANG Suite is Cisco’s GUI tool for exploring YANG models, constructing RPC payloads, and testing them against live devices.
Installation (Docker)
# Clone the official repositorygit clone https://github.com/CiscoDevNet/yangsuite.gitcd yangsuite/docker# Start YANG Suitedocker-compose up -d# Access at https://localhost:8443
Workflow
1. Add YANG Repository → Upload .yang files or pull from device
2. Browse Models → Explore tree structure in the GUI
3. Build RPC Payload → Click nodes to construct XML/JSON
4. Select Protocol → NETCONF or RESTCONF
5. Connect to Device → Enter credentials and execute
6. View Response → See device output in the GUI
YANG Suite for Payload Construction
YANG Suite can generate both JSON and XML payloads by clicking through the model tree. This is the fastest way to build correct payloads without manually parsing YANG files.
Using YANG Suite to Construct a JSON Payload
Navigate to Protocols > RESTCONF in the sidebar
Select the YANG model (e.g., ietf-interfaces)
Expand the tree and check the nodes you need
Fill in values for leaves (e.g., name = Loopback100)
Click Build JSON — the tool generates the correct payload
Copy and use in your Python script
Using YANG Suite to Construct an XML Payload
Navigate to Protocols > NETCONF
Select the YANG model and expand the tree
Check desired nodes, fill in leaf values
Click Build RPC — generates a complete <edit-config> or <get-config> XML
Optionally execute directly against a connected device
pyang
pyang is a command-line tool for validating, transforming, and visualizing YANG models.
Installation
pip install pyang
Key Commands
# Generate human-readable tree view (most common)pyang -f tree ietf-interfaces.yang# Tree view with augmentations from ietf-ippyang -f tree ietf-interfaces.yang ietf-ip.yang# Limit tree depthpyang -f tree --tree-depth 3 Cisco-IOS-XE-native.yang# Filter tree to a specific pathpyang -f tree --tree-path /interfaces/interface ietf-interfaces.yang# Generate HTML tree (interactive)pyang -f jstree -o interfaces.html ietf-interfaces.yang# Generate XML skeleton payloadpyang -f sample-xml-skeleton ietf-interfaces.yang# Validate model strictlypyang --strict --lint ietf-interfaces.yang# Show module dependenciespyang -f depend ietf-interfaces.yang# List all modules in a repositorypyang -f name *.yang
RFC 8340 defines a standard text-based notation for representing YANG module structures. This is the format output by pyang -f tree and is the format used in exam questions.
“Which JSON/XML path corresponds to this node?” — trace the hierarchy
“Is this field read-write or read-only?” — check rw vs ro
“Which fields are mandatory?” — no ? after the name
“What is the list key?” — shown in [brackets]
“Can you set oper-status via RESTCONF?” — no, it’s ro
5 – Putting It All Together — YANG to API Call Workflow
┌─────────────────────────────────────────────────────────────┐
│ Step 1: Identify Feature │
│ "I need to configure a Loopback interface with an IP" │
└──────────────────┬──────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 2: Find the YANG Model │
│ → ietf-interfaces + ietf-ip (augment) │
│ → Or: Cisco-IOS-XE-native for full vendor features │
│ Tools: YANG Suite, pyang, GitHub YANG model repos │
└──────────────────┬──────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 3: Explore the Model Tree │
│ → pyang -f tree ietf-interfaces.yang ietf-ip.yang │
│ → Or browse in YANG Suite GUI │
│ → Identify required leaves, list keys, data types │
└──────────────────┬──────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 4: Construct Payload (JSON or XML) │
│ → Map containers to objects, lists to arrays │
│ → Include module prefixes │
│ → Fill in required leaf values │
└──────────────────┬──────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ Step 5: Choose Protocol and Execute │
│ NETCONF → ncclient + XML payload │
│ RESTCONF → requests + JSON payload │
│ See [[Catalyst_Center_Deep_Dive]] for controller examples │
└─────────────────────────────────────────────────────────────┘
Which family of YANG model is being used?
A. IETF standard model
B. Cisco native model
C. OpenConfig model
D. Vendor-neutral NETCONF model
Answer
C. OpenConfig model
The namespace http://openconfig.net/yang/... identifies OpenConfig models. IETF uses urn:ietf:params:xml:ns:yang:... and Cisco native uses http://cisco.com/ns/yang/....
Scenario 2 — RESTCONF Method Selection
An engineer wants to update the description of an existing interface without replacing any other configuration on that interface. Which HTTP method should be used?
A. GET
B. POST
C. PUT
D. PATCH
Answer
D. PATCH
PATCH performs a merge operation — it updates only the specified fields without affecting others. PUT would replace the entire resource. POST would fail with 409 Conflict because the interface already exists.
Which statement is true?
A. The description field is mandatory
B. The oper-status can be set via RESTCONF PUT
C. Multiple interface entries can exist in the list
D. The name field is optional
Answer
C. Multiple interface entries can exist in the list
The * after interface means it is a list with 0..n entries. description? (with ?) is optional, so A is wrong. oper-status is ro (read-only), so B is wrong. name is the list key [name] and therefore mandatory, so D is wrong.
Scenario 4 — NETCONF vs RESTCONF Capability
A network automation team needs to stage configuration changes, validate them, and then commit them atomically to multiple devices. Which protocol best supports this workflow?
A. RESTCONF with PATCH method
B. NETCONF with candidate datastore
C. RESTCONF with PUT method
D. NETCONF with running datastore only
Answer
B. NETCONF with candidate datastore
The candidate datastore allows staging changes (edit-config target="candidate"), validating them (<validate>), and then atomically applying them (<commit>). RESTCONF does not support candidate datastores. Using running datastore only does not allow staging/validation before applying.
A YANG list maps to a JSON array of objects. Each list entry is an object containing the key leaf (address) and any other leaves. Option B incorrectly treats address as a leaf-list. Options C and D do not match the YANG structure at all.
Scenario 6 — pyang Usage
An engineer needs to see the hierarchical structure of the openconfig-bgp YANG model in a terminal. Which pyang command is correct?
A. pyang --format xml openconfig-bgp.yang
B. pyang -f tree openconfig-bgp.yang
C. pyang -f json openconfig-bgp.yang
D. pyang --validate openconfig-bgp.yang
Answer
B. pyang -f tree openconfig-bgp.yang
The -f tree flag generates the human-readable RFC 8340 tree diagram. -f xml is not a valid pyang output format for viewing structure. -f json is not the correct format for tree views. --validate would check the model for errors, not display its structure.
8 – Quick Reference Cheat Sheet
Key YANG Terms
Term
One-Liner
module
Top-level YANG file; defines a complete data model
container
Grouping node; JSON object, XML element
list
Keyed collection; JSON array of objects
leaf
Single value; JSON key-value pair
leaf-list
Array of scalars (like a list but without keys)
augment
Adds nodes to another module’s tree
deviation
Declares vendor differences from a model
grouping
Reusable node template (like a macro)
typedef
Custom data type definition
choice/case
Mutually exclusive branches
identityref
Reference to a YANG identity (needs module prefix)
presence container
Container whose existence alone has meaning (! in tree)
NETCONF vs RESTCONF — One-Liner Comparison
NETCONF
RESTCONF
Port
830 (SSH)
443 (HTTPS)
Encoding
XML
JSON or XML
Candidate
Yes
No
Locking
Yes
No
Session
Persistent
Stateless
Best for
Transactions
Quick CRUD
Common YANG Namespaces
Family
Namespace Pattern
Example
IETF
urn:ietf:params:xml:ns:yang:{model}
urn:ietf:params:xml:ns:yang:ietf-interfaces
OpenConfig
http://openconfig.net/yang/{model}
http://openconfig.net/yang/interfaces
Cisco Native
http://cisco.com/ns/yang/{model}
http://cisco.com/ns/yang/Cisco-IOS-XE-native
IANA
urn:ietf:params:xml:ns:yang:iana-{type}
urn:ietf:params:xml:ns:yang:iana-if-type
pyang Cheat Sheet
pyang -f tree model.yang # Tree view (RFC 8340 format)pyang -f tree --tree-depth 3 model.yang # Limit depthpyang -f tree --tree-path /path model.yang # Filter to subtreepyang -f tree model.yang augment.yang # Include augmentationspyang -f jstree -o out.html model.yang # Interactive HTML treepyang -f sample-xml-skeleton model.yang # XML skeleton payloadpyang --strict --lint model.yang # Validate modelpyang -f depend model.yang # Show dependencies