Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A collection of Python Code Samples for Network Management. Includes samples to run on-box and off-box.

License

NotificationsYou must be signed in to change notification settings

CiscoDevNet/python_code_samples_network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

A collection of Python Code Samples for Network Management. Includes samples that leverage on-box libraries, as well as samples that use exposed external APIs (NETCONF/RESTCONF, SNMP, SSH, REST, etc). Some examples make use of available SDKs.

On-Box Examples

Many Cisco switches and routers provide an on-box Python Interpreter that can be leveraged to execute scripts and programs directly on end devices. In addition to the interpreter, Python libraries are included that provide direct access to the underlying devices operations to execute CLI commands, or monitor for events.

Sample Code

Code SampleDescription
Execute CLI via PythonThis example is about as simple as it gets. By leveraging the CLI library, we execute the “show version” command on the box.
TDR Test Every InterfaceThis example once again leverages the CLI library, but to do something a bit more interesting. A TDR test is run on every interface in “up” status.
EEM Config Changes to SparkIn this example, the EEM library is used to monitor for configuration changes. When one occurs a message is sent to a Cisco Spark Room.
Python with Eventing ExampleUse the EEM and Python together to script based on local events.
EEM + Python + Spark ChatOpsUse the EEM to monitor for config changes and send a Spark Message
EEM + Python + Email alertThis example leverages the CLI library and using the EEM feature to monitor for interface flapping and send an email alert

Off-Box Examples

Here are few Python scripts that can interact with network elements using one of the many exposed interfaces (NETCONF, RESTCONF, SNMP, SSH, etc). Many of these scripts could also be run on-box, however they don’t leverage any of the unique libraries available on device.

Code SampleDescription
Netmiko and CLI Example for Interface ManagementThese are a series of python scripts for retrieving, creating, deleting a Loopback Interface with Python.
MIB Walk with PythonIn this example, we perform a MIB walk against a device leveraging the “netsnmp” library for Python.
NETCONF Connection with PythonThis example shows the basics of connecting to a device with NETCONF using the “ncclient” library for Python.
Configure Interface IP Address with RESTCONFIn this example the newly ratified RESTCONF standard is used to configure the IP Address on an interface.
Get Inventory from APIC-EMAPIC-EM maintains an inventory database of the entire network. In this example Python is used to retrieve that information using the REST API.
Get Host List from APIC-EMAPIC-EM maintains a list of all clients connected to the network devices discovered by APIC-EM. This example queries the APIC-EM for the list, and display’s it in a simple table.
Retrieve Tenants from ACI APICThis example leverages the ACI Toolkit to connect to an APIC controller and retrieve the list of Tenants configured.
Basic NETCONF GetA basic ncclient example to<get> NETCONF Data
Basic NETCONF EditA basic ncclient example to<edit-config> NETCONF Data
NETCONF XPATH ExampleUse the XPATH feature when making a NETCONF Requests
Model Based AAAThese example scripts are for Model Based AAA to get, edit and delete the rule-lists for privilege level users and Groups by using ietf-netconf-acm.yang data model
RESTCONFThese example scripts are for RESTCONF to retrieve and configure the switch using different operations such as Get, Delete, Put, Post and Patch.

About

A collection of Python Code Samples for Network Management. Includes samples to run on-box and off-box.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp