PortAudit

Description

Script that iterates over a list of network devices (i.e switches, routers) specified on a CSV file and generates a report of their port status (Interface name, description, IP address and Administrative status).
It does this using the RESTCONF Protocol.

About the LAB to run the demo.

The routers.csv file contains the CSR1000v Always-on DevNet sandbox as part of this demo.
Sandbox URL: https://devnetsandbox.cisco.com/RM/Diagram/Index/27d9747a-db48-4565-8d44-df318fce37ad?diagramType=Topology

CSR1000V Host: ios-xe-mgmt.cisco.com

SSH Port: 8181

NETCONF Port: 10000

RESTCONF Ports: 9443 (HTTPS)

Credentials of this public available Sandbox to specify when prompted for it:

Username: developer

Password: C1sco12345

Usage

  1. Clone this repo in your local machine typing on your terminal:

https://github.com/agmanuelian/PortAudit.git

  1. Install the required dependencies specified on the requirements.txt file:

pip install requirements.txt

  1. Edit the routers.csv file with the parameters (IP address and RESTCONF port) of the list of devices that you want to configure.

Alt text

  1. Modify on the port_audit.py script the directory from where the routers.csv file is read, specifying your local directory. Also, modify the directory where output_interfaces.csv will be written to.
  2. Run the port_audit.py script.
  3. You will be prompted to enter your TACACS credentials (demo credentials specified on previous section) to access the list of devices.
  4. The script will run the report, display it on the terminal and write the output_interfaces.csv file (the port audit results) to the specified directory.

Terminal output

Alt text

Output CSV file, with the port audit results

Alt text

REF: TACACS is a network device access management protocol. If you have that configure to access all your network devices, you could use your TACACS credentials to access the network devices. Otherwise, using local authentication will work, too.

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
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.