YANG-GETTER


date: "2020-15-10"
tags: ["nornir", "YANG"]

Dependencies

pip3 install nornir"<3"
pip3 install rich
pip3 install requests

Overview

This script uses the Nornir framework (version 2!) to simplify the retrieval of device (Cisco IOS-XE) information over RESTCONF.
Simply select a keyword and the yang_getter.py script will translate the selection into the correct resource URL and send a HTTP GET request to the targeted devices.
Data will be returned as a Python dictionary, in form of the Cisco IOS-XE Native YANG model

How to Use

Simply run the script by typing python3 yang_getter.py and the script will execute. First a table will appear demonstrating all of the available keywords, after which you can simply type the keyword of the resource you would like to retrieve! Be aware, if you try to pull a resource that isn't configured on the device you will receive an error!
For example, if you use the "eigrp" keyword - EIGRP must be present on the device.
If a particular configuration is not present you can simply add it via the CLI, logging in with the command:
ssh developer@ios-xe-mgmt.cisco.com -p 8181 and providing the password of C1sco12345.
Alternatively, you can configure the always-on Sandbox using other tools such as Postman.

DEVNET SANDBOX INFORMATION

This script has been designed on operate on the Cisco IOS-XE Always on Sandbox with 16.9.3 code.
The newer version of this code has a slightly different YANG implementation and will break the "ospf" and "eigrp" features, due to a container name-change!
You can find a list of Cisco XE sandboxes here: https://developer.cisco.com/docs/ios-xe/#!sandboxes/reservation-based-sandboxes

DEMO

alt text

alt text

alt text

About Me

My name's John McGovern, I maintain a Youtube channel called IPvZero and I am trainer for CBT Nuggets.
I create instructional videos on Python Network Automation.

Contact

Twitter

Youtube

LinkedIn

CBT Nuggets

Advanced Network Automation with Cisco and Python

Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.