This repository contains a Python Flask application that automate the process of onboarding devices using Plug and Play (PnP) in Cisco DNA Center. The scripts address use cases where devices are onboarded without knowing the serial number in advance, which is a common scenario when a site has a specific IP subnet allocated to it.
The scripts utilize the webhook notification option of Cisco DNA Center's "unclaimed" process. When a device contacts DNAC, information such as its IP address and serial number is sent via webhook to our Flask application. The application then maps the IP subnet to a configuration file that includes parameter mapping to variables, and claims the device based on its IP address.
Feel free to contribute to this repository and enhance the automation process further.
Create a virtual environment and install the packages according to the requirements.txt
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
Minimum version > 2.3.3.x
Choose Platform > Developer Toolkit > Event Notifications > Notifications
Click + to create a new notifaction
Step 1 - Select Site and Events
Search for Device waiting to be claimed
, select the notification and click Next
Step 2 - Select Channels
Choose the Rest as a notification channels and click Next
Step 3 - REST Settings
Click here to create a new setting instance. This opens the page below:
System > Settings > External Services > Destinations
Click add and fill in the details based on the example:
Return to the Step 3 - REST Settings page, refresh the instance select the created instance:
Click on Next
Step 4 - Name and Description
Provide a name and short description for your notification and click on Next
On the Summary page click on Finish
Done! Your new notification is complete.
Set credentials as environment variables:
$ cat mycredentials.sh
DNA_CENTER_USERNAME=your_username_here
DNA_CENTER_PASSWORD=your_password_here
Run application:
$ source venv/bin/activate
$ source mycredentials.sh
$ python flaskapp.py
Choose Design > Network Hierarchy and click Import Sites
Choose a file or drag and drop to upload: /test_files/Test_Sites.csv
Click Upload and then Import
Choose Tools > Template Editor and click Onboarding Configuration
Hover over the project Onboarding Configuration, click the gear icon, and click Import Template
import the template from /test_files/C9k_Onboarding-Template.json
Choose Provision > Network Devices > Plug and Play and click on Add Devices
Select Bulk Devices and the devices using /test_files/Test_DeviceImportTemplate.csv
Select the Devices and click on add
Choose Platform > Developer Toolkit > Event Notifications > Event Catalog
Search for Device waiting to be claimed
Webhook Switch test payload
{
"ipAddress": "172.20.101.2",
"deviceName": "JAE231609EK"
}
Webhook AP test payload
{
"ipAddress": "172.20.201.10",
"deviceName": "FCW2433P1L7"
}
Smart people responsible for the creation and maintenance of this project:
- Anna Summerauer asummera@cisco.com
- Patrick Mosimann pamosima@cisco.com
To streamline the onboarding process, we have leveraged multiple scripts available on the CiscoDevNet/DNAC-onboarding-tools GitHub repository. Our scripts provide an efficient and automated solution to onboard devices in Cisco DNA Center, improving network provisioning time and reducing manual effort.
This project is licensed to you under the terms of the Cisco Sample Code License.
Please post any issues or comments directly on GitHub.