published
Code style: black
Imports: isort
GitHub commit activity
GitHub contributors
GitHub Issues or Pull Requests by label
GitHub Issues or Pull Requests by label
GitHub License

Webhook Testing with Cisco Catalyst Center (a.k.a DNA Center)

Objective

This project is a Proof of Concept (PoC) for the use of webhooks with Cisco SDN solutions, specifically integrating with Cisco Catalyst Center. It leverages a Flask application to receive and process webhook notifications in real-time, showcasing how events from the Cisco Catalyst Center can be handled programmatically.

Webhook Receiver Up Webhook Receiver Down
Server Up Server Down

Table of Contents

Features

^ back to top ^

  • Webhook Integration: Receive and process notifications from Cisco Catalyst Center.
  • Websockets: Enable ongoing, full-duplex, bidirectional communication between client and server.
  • Real-time Updates: Display incoming notifications in a dynamically updating dashboard web page.
  • Authentication: Secure webhook endpoints with basic authentication.
  • Notification Sound: Play a sound when a new notification is received.
  • Pagination: Display event notifications in a paginated format.

Prerequisites

^ back to top ^

  • Python 3.9+
  • Flask
  • Cisco Catalyst Center with webhook enabled

Installation

^ back to top ^

  1. Clone the repo
$ git clone https://github.com/Tes3awy/cisco-catalyst-center-webhooks.git
$ cd cisco-catalyst-center-webhooks
  1. Setup a virtual environment (Optional but recommended)
$ python -m venv .venv
$ source .venv/bin/activate . # On Windows, use `.\.venv\Scripts\Activate.ps1` in powershell
(.venv)$ 
  1. Install SQLite3

Linux

$ sudo apt update && sudo apt upgrade -y
$ sudo apt install sqlite3 -y
$ sqlite3 --version

Windows

Follow this tutorial

  1. Install dependencies
(.venv)$ pip install -r requirements.txt
  1. Set private environment variables

Create a .env file in the root directory and add the following:

BASIC_AUTH_USERNAME="USERNAME"
BASIC_AUTH_PASSWORD="PASSWORD"
  1. Run the application
(.venv)$ flask run
 * Serving Flask app 'run'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on https://127.0.0.1:5443
Press CTRL+C to quit   
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 419-253-304
***** Copy Headers for Cisco Catalyst Center Webhook *****
 Authorization: Basic YWRtaW46Q2lzY28hMjM0NQ==
 Content-Type: application/json
***** Copy Headers for Cisco Catalyst Center Webhook *****
  1. Configure Cisco Catalyst Center
  • Navigate to System > Settings > External Services > Destination > Webhook in the Catalyst Center dashboard.
  • Add a new POST webhook with the Webhook URL https://<ip_address>:5443/api/v1/webhook.
  • For the Trust Certificate radio button, choose No.
  • For Authentication, choose Basic and set the required headers:
    • Content-Type: application/json
    • Authorization: Basic <BASE64 of username:password>
  • Configure a webhook destination for an event. (Refer to the references section)

Usage

^ back to top ^

Once the application is running, it will listen for webhook notifications from Cisco Catalyst Center. When a notification is received, it will be displayed on the dashboard in real-time.

Use Case

This project can be used to monitor and respond to events from Cisco Catalyst Center in real-time. For example, you can use it to:

  • Monitor network changes, such as device additions, deletions, or modifications.
  • Monitor network performance and troubleshoot issues in real-time.
  • Trigger automated responses to network events, such as sending alerts or notifications.
  • Analyze network data and trends over time.

Security Considerations/Improvements

^ back to top ^

  • Use HTTPs to secure webhook communications.
  • Validate all incoming requests using a custom authentication token.

Debugging Tips

^ back to top ^

Check the Flask application logs in the terminal for errors and/or warnings.

Author(s)

^ back to top ^

This project was written and is maintained by the following individuals:

Getting involved

^ back to top ^

Contributions are welcome! Please open an issue or submit a pull request with improvements or bug fixes.

References

^ back to top ^

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.