published
Tested on Python 3.9.6
Language
Issues Open
Commit Activity
Last Commit
Code Size
Contributions Welcome
License
Code style: black
Imports: isort
Pre-Commit

Cisco DNA Center Device List, Device Config, and Network Health

This program is designed to export a Cisco DNAC device list and save them to an Excel sheet, device configurations and save them to text file, and network health and generate a bar chart.

Table of Contents

  1. Installation
  2. Getting Started
  3. Usage
  4. Collected Data from Device List Response
  5. Use it for your DNA Center
  6. References
  7. Previews

Installation

$ git clone https://github.com/Tes3awy/Cisco-DNA-Center-Device-List.git
$ cd Cisco-DNA-Center-Device-List
$ pip install -r requirements.txt --user

Getting Started

│   main.py
│   get_auth_token.py
│   get_device_list.py
│   get_device_config.py
│   get_network_health.py
│   export_device_list.py
│   export_device_config.py
│   export_network_health.py
│   notify.py
│   .env.example
│   requirements.txt
│   README.md
│   CONTRIBUTING.md
│   CODE_OF_CONDUCT.md
│   .pre-commit-config.yaml
│   .gitignore
│   LICENSE
│
├───.github
│   └───ISSUE_TEMPLATE
│           bug_report.md
│           feature_request.md
│
└───assets
        preview.png
        sandboxdnac2.cisco.com.jpg
        script-logs.png

Usage

You need to provide your Cisco DNA Center credentials in a .env file. Create a .env file from .env.example and DON'T delete the latter (Check Use it for your DNA Center section).

A .env file in the current working directory will override the .env.example values.

Then run:

python main.py

Voila ✨! An Excel file is created automatically from the device list on Cisco DNAC in the current working directory, configuration files of those devices are created in configs/<DOMAIN>/<today>/<config_id>_<today>.txt, and a network health diagram (a bar chart with a legend) is created in net_health/<BASE_URL>-<today>.jpg.

Unlike handling text files, XlsxWriter library does not have the option of appending new data to an existing Excel file. So every time you run the script, the Excel file will be overwritten.

NOTE: You have to close the Excel program before re-running the script.

For Windows Users ONLY

You will be notified with a native toast notification upon script successful completion.
Toast Notification

Collected Data from Device List Response

  1. Hostname
  2. Device ID
  3. Management IP Address
  4. Serial Number
  5. Mac Address
  6. Platform ID (Device Model)
  7. Software Version
  8. Role
  9. Up Time
  10. Last Update
  11. Reachability Status

Use it for your DNA Center

This program is ready to be used for your deployed Cisco DNA Center.

Create a .env file from .env.example:

$ cp .env.example .env

Repalce the .env file values with your Cisco DNA Center credentials.

Example:

.env

DOMAIN=10.10.1.1 # without a trailing slash (/)
PORT=443
BASE_URL=https://${DOMAIN}:${PORT}
USERNAME=root
PASSWORD=C1sco12345
SSL_CERTIFICATE=False  # set to True ONLY if you have a valid SSL certificate

References

API Endpoints

DNA Center Platform

Documentation

Cisco DNA Assurance User Guide

Previews

Script Logs
Script Logs

Excel File Preview
Excel File Preview

A demonstration for color formatting
Network Health Bar Chart

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.