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.
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
Run "main.py"
# 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.
Owner
Contributors
Categories
Products
Cisco Catalyst CenterProgramming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community