10-24-2023 08:20 AM
I am running the dna/intent/api/v1/network-device/config API which is getting the config for all devices at once. what is the meaning of ID in the response for the API? I assumed it is the same ID in dna/intent/api/v1/network-device 'Get Device List' but running both APIs on DNAC sandbox shows that these 'ID' values in the response are different. My main goal is to use the ID in the response dna/intent/api/v1/network-device/config response to then get the hostname from the dna/intent/api/v1/network-device API and store the config in a file based on it's hostname. below is a script that show the ID response from both of these APIs is not the same
using dnacentersdk 2.6.3
from dnacentersdk import api
from dnac_config import DNAC_USER, DNAC_PASSWORD, DNAC
import urllib3
from pprint import pprint
import json
import re
urllib3.disable_warnings()
from datetime import datetim
def main():
#login
dnac = api.DNACenterAPI(base_url=DNAC, username=DNAC_USER, password=DNAC_PASSWORD, verify=False)
a = dnac.devices.get_device_config_for_all_devices()
y = []
for item in a['response']:
y.append(item['id'])
pprint(y)
b = dnac.devices.get_device_list()
x = []
for item in b['response']:
x.append(item['id'])
pprint(x)
RESULT:
['19886bba-a2d2-4c69-a89c-44b4441c9df5',
'420778b9-7a54-4a85-a6cf-db4761257aa8',
'465afcf8-03db-4554-a7bd-653036d02d10']
['32446e0a-032b-4724-93e9-acbbab47371b',
'c069bc2c-bfa3-47ef-a37e-35e2f8ed3f01',
'5f03d9a9-33df-450e-b0c3-6bcb5f721688']
10-25-2023 10:36 AM
It's probably a config id, not a device id. You may not need to reinvent the wheel here. Look around the published github repos for solutions others have put together, such as https://github.com/CiscoSE/dnac_network_device_config_archiver_poc
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide