Interact with IOS XE via NETCONF/YANG using ncclient and RESTCONF using Python requests. Configure model-driven telemetry.
show platform software yang-management processpython3 netconf_restconf_example.pycurl -k -u admin:Lab@2024#EI https://10.255.1.1/restconf/data/ietf-interfaces:interfacesshow interface Loopback99show telemetry ietf subscription allshow telemetry internal connectionNETCONF (RFC 6241) is an XML-based protocol for network configuration, running over SSH (port 830). YANG (RFC 6020/7950) defines the data models. NETCONF operations: get-config (read), edit-config (write), get (operational data). The ncclient Python library handles the SSH/NETCONF session, XML namespaces, and RPC envelope.
RESTCONF (RFC 8040) provides a REST API over HTTPS using JSON or XML encoding. It uses standard HTTP methods: GET (read), PUT (replace), PATCH (merge), POST (create), DELETE (remove). The base URL is /restconf/data/{module}:{container}/{list}={key}. Content-Type must be 'application/yang-data+json' or +xml.
Model-driven telemetry (MDT) pushes operational data from the router to a collector at configurable intervals or on change, using gRPC transport. Unlike SNMP polling (pull), MDT is push-based, reducing collector load and providing faster visibility. The 'on-change' subscription type sends data only when a YANG leaf value changes — ideal for event-driven monitoring.
Verify 'netconf-yang' is in running config. Check port 830 not blocked by ACL. NETCONF requires 'aaa new-model' and a local user with privilege 15.
Basic auth must use correct credentials. Verify 'restconf' in config. Check 'ip http secure-server' is enabled. SSL certificate warning is expected in lab — use 'verify=False' in Python requests.
Verify gRPC collector is running and reachable. Check 'show telemetry internal connection' for errors. Some IOS XE versions require 'ip http client source-interface' for telemetry to source correctly.
Attempt the tasks yourself before viewing solutions.
Type SOLUTION to unlock.
Python Script
# See netconf_restconf_example.py in this lab folder
Research and direction by Ioannis (John) Konstas; compiled and finalized with AI assistance.