Updating Inventory using DNA-C with Chatbot Notification bot
- Eda Akturk ([email protected])
- Python 3.8
- DNA-Center
- Webex
- MySql Database 8.0
$ git clone https://github.com/gve-sw/DNACenterInventoryWebexIntegration.git
Initialize a virtual environment
virtualenv venv
Activate the virtual env
Windows venv\Scripts\activate
Linux source venv/bin/activate
Now you have your virtual environment setup and ready
$ pip install requirements.txt
Cisco DNA Center Connection
-
Obtain the username, password and base url for your Cisco DNA Center environment.
-
Export the following information as environment variables so it is possible to connect to the Cisco DNA Center API.
DNAC_URL = env_lab.DNA_CENTER["host"]
DNAC_USER = env_lab.DNA_CENTER["username"]
DNAC_PASS = env_lab.DNA_CENTER["password"]
Cisco Webex Bot
-
Create a Webex Bot. Webex Bots can be created from the Cisco Developer website. https://developer.webex.com/docs/bots
-
Add the access token for the Webex Bot.
ACCESS_TOKEN = "ACCESS_TOKEN"
- Fill the email address of a user or group to recieve the webex notification.
to = ' EMAIL_ADDRESSS'
Database Connection
-
Download and Install MySQL.
-
Create a table in MySQL database with the following script. You can run the script from MySQL Workbench.
CREATE TABLE `allDeviceDetails` (
`hostname` varchar(255) DEFAULT NULL,
`ip` varchar(255) DEFAULT NULL,
`serial` varchar(255) NOT NULL,
`platformId` varchar(255) DEFAULT NULL,
`version` varchar(255) DEFAULT NULL,
`role` varchar(255) DEFAULT NULL,
`uptime` varchar(255) DEFAULT NULL,
`createDate` varchar(255) DEFAULT NULL,
`updateDate` varchar(255) DEFAULT NULL,
PRIMARY KEY (`serial`)
)
Now you have completed the setup and are ready to run the script.
Run the python script
$ python inventory_update.py
The Webex Bot will send the list of Network devices which have been updated in the database:
Provided under Cisco Sample Code License, for details see LICENSE
Our code of conduct is available here
See our contributing guidelines here
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.