Automatically update device management from IP to DNS
This script is made for situations where DNAC users cannot rely on IP address to identify and manage devices, and need a dynamic, automated, and human friendly way to name and manage devices.
- DNAC generate a DNS name for the device through Day 0 template and provision/onboard the device
- Device boots and register DNS name automatically
- Run this script to update DNAC to manage these devices with DNS name instead of IP This script can also be run priodically to scan for new device onboarded and update their device information automatically
Before you start, please make sure you're running python version 3 and up. If you have multiple versions on the system, please run this by specifying Python version, for example,
python3 main.py
Or you can use venv, for example
python3 -m venv dns-automation
On Windows, run
dns-automation\Scripts\activate.bat
On Linux/Unix or MacOS, run
source dns-automation/bin/activate
Also, please make sure all the required packages are installed by issueing the following
pip install -r requirements.txt
This will make sure the modules are available so you won't see errors during import
-
Configuration file Update "Config.py" with information of your environment. Wha'ts currently provided was DNAC Sandbox. You can use this for test but you wouldn't be able to make changes. When you run the script you will get a HTTP 403 code becuase you won't have access to make change on Sandbox.
### Use this file to configure access to DNAC ### Replace all values below with your production DNAC ### Provided is DNAC sandbox login DNAC_FQDN = 'sandboxdnac.cisco.com' DNAC_PORT = '443' DNAC_USER = 'devnetuser' DNAC_PASSWORD = 'Cisco123!' ### SCOPE of devices thi script is going to manipulate, this need to be the same as "Series" field of the device SCOPE = ["Cisco Catalyst 9300 Series Switches", "Cisco Catalyst 9200 Series Switches"] ### Optoinal - Domain that all devices belong to, for example ".cisco.com", the hostname of the device would be "device.cisco.com" DOMAIN = ".abc.inc"
-
Make sure you have all 3 files
- config.py - stores configuration as described in # How to use item 1
- util.py - functions needed to run the script
- main.py - main script
-
Run "main.py"
- Expected results
# If "No" is chosen update operations will be canceled Parsing device list... Found new device, collecting information... Found new device, collecting information... ================================================================================ Parsing complete, here is a list of devices that needs updated, please confirm... ================================================================================ 10.10.22.66: Cisco Catalyst 9300 Series Switches 10.10.22.70: Cisco Catalyst 9300 Series Switches Confirm to update devices [Y/N]? n ================================================================================ Task canceled, exiting... ================================================================================
# If "Yes" is chosen update operations proceed and devices will be updated Parsing device list... Parsing device list... Found new device, collecting information... Found new device, collecting information... ================================================================================ Parsing complete, here is a list of devices that needs updated, please confirm... ================================================================================ 10.10.22.66: Cisco Catalyst 9300 Series Switches 10.10.22.70: Cisco Catalyst 9300 Series Switches Confirm to update devices [Y/N]? y Confirmed, updating devices... ================================================================================ Task completed, exiting... ================================================================================
# If you're using the sandbox or don't have access to make changes, the following error will be seen Parsing device list... Found new device, collecting information... Found new device, collecting information... ================================================================================ Parsing complete, here is a list of devices that needs updated, please confirm... ================================================================================ 10.10.22.66: Cisco Catalyst 9300 Series Switches 10.10.22.70: Cisco Catalyst 9300 Series Switches Confirm to update devices [Y/N]? y Confirmed, updating devices... ================================================================================ Unauthorized to make a change! Existing... ================================================================================ Operation failed, exiting... ================================================================================ Unauthorized to make a change! Existing... ================================================================================ Operation failed, exiting... ================================================================================ Task completed, exiting... ================================================================================
Thank you. If there's any issue please feel free to contact the author.