Chat with Us!

Explore Python sample code

On-Box Python

Example scripts that leverage Cisco provided Python libraries allowing access to the configuration, operational state, or event data from the network element.

Execute CLI via Python

Leverage the CLI library to execute the “show version” command on the box.

TDR Test Every Interface

Leverage the CLI library with a TDR test run on every interface in “up” status.

EEM Config Changes to Spark

Monitor configuration changes and send a message to a Cisco Spark Room.

Off-Box Python

Examples that leverage one of the many exposed interfaces (NETCONF, RESTCONF, SNMP, SSH, etc) on a network element within a script.

MIB Walk with Python

Perform a MIB walk against a device leveraging the “netsnmp” library.

NETCONF Connection with Python

Connect to a device with NETCONF using the “ncclient” library for Python.

Boot Integrity Verification (BIV)

Analyze the Boot Integrity report to validate its authenticity and integrity.

Python & Network Controllers

In addition to using Python to automate device by device, Python can be used to interact with Network Controllers such as APIC-EM, APIC, or OpenDaylight.

Get Inventory from APIC-EM

Retrieve inventory database information of the entire network using the REST API.

Get Host List from APIC-EM

Query and display a table of all clients connected to network devices.

Retrieve Tenants from ACI APIC

Leverage the ACI Toolkit to retrieve the list of tenants configured on an APIC controller.

Develop with Python SDKs and Tools

Learn YDK with Python for NETCONF/YANG

Hello World for YDK-Py

A collection of sample applications that use YDK-Py for network programmability. The script prints the uptime of a device running Cisco IOS XR.

Basic YDK-Py Apps

These apps illustrate simple examples of using YDK-Py to program a network device. They do not require significant model or programming experience.

YDK Learning Lab

Leveraging YANG Development Kit (YDK) for Programmatic Access to Network Devices.

Get started with On-Box Python and GuestShell on IOS XE

Check out these docs to learn more


CAT 3650 CAT 3850 ISR 4K Nexus 3K/9K Nexus 5K/6K Nexus 7K
Python 2.7 IOS-XE 16.5.1 IOS-XE 16.5.1 IOS-XE 16.5.1 N3K NX-OS 6.0
N9K NX-OS 7.0
N5K NX-OS 5.2
N6K NX-OS 6.0
NX-OS 6.1
Python 3.x N/A N/A IOS-XE 16.5.1

Do you have any questions?

Join the discussion with the Networking experts and peers!

Looking for more resources?

Check out what Cisco Digital Networking Architecture is all about.