cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2849
Views
24
Helpful
8
Replies

Get Device location from DNA-Center API

rschroeder1006
Level 1
Level 1

Hello all,

I am searching for a way to get the location of all devices from DNA-Center via API.

The only solution I found is to first get a list of device IDs (/intent/api/v1/network-device) and then get the details for every device (/intent/api/v1/device-detail?identifier=uuid&searchBy=...). The response then contains the 'location' key, this is what I need.

The problem is that we have thousands of devices, so thousands of API calls and minutes to hours of waiting. There should be a simpler solution, but I don't see it.

Can anyone give me a hint on how to get the location of every device from DNA-Center in a single (or just a few) API call?

Robin

8 Replies 8

Mike.Cifelli
VIP Alumni
VIP Alumni

What version of DNAC are you running? I know with 2.2.3.x APIs you can use this API to get location: Get Network Device By IP

 /dna/intent/api/v1/network-device/ip-address/{ipAddress}

Example return payload:

{ "response": { "apManagerInterfaceIp": null, "associatedWlcIp": null, "bootDateTime": null, "collectionInterval": null, "collectionStatus": null, "errorCode": null, "errorDescription": null, "family": null, "hostname": null, "id": null, "instanceTenantId": null, "instanceUuid": null, "interfaceCount": null, "inventoryStatusDetail": null, "lastUpdateTime": null, "lastUpdated": null, "lineCardCount": null, "lineCardId": null, "location": null, "locationName": null, "macAddress": null, "managementIpAddress": null, "memorySize": null, "platformId": null, "reachabilityFailureReason": null, "reachabilityStatus": null, "role": null, "roleSource": null, "serialNumber": null, "series": null, "snmpContact": null, "snmpLocation": null, "softwareType": null, "softwareVersion": null, "tagCount": null, "tunnelUdpPort": null, "type": null, "upTime": null, "waasDeviceMode": null }, "version": null }

 

rschroeder1006
Level 1
Level 1

Hello Mike,

I am on version 2.2.3.3 now (was 2.2.2.x until yesterday), but no matter which device I look at, the "location" attribute in /dna/intent/api/v1/network-device/ip-address/{ipAddress} ist always "null", whereas the "location" attribute in /intent/api/v1/device-detail?identifier=uuid&searchBy={id} shows what I want, i.e. the "Global/Area/Building/Floor" string that the device is assigned to.

Was an answer ever found for this?  Currently looking for a way to grab the location of a device via API.  The Get device list call says this field is a map type.  Only map info I see is wireless related, I want everything which wouldnt get added to a wireless AP map.. 

 

It does not look like there is a solution. The official API does not present the location.

 

No, no answer yet.

Just to update on what info i have found. Is that the value is correlated to what SNMP location the device has and not the folder in inventory you placed a device. frustrating. that is why 2 calls are needed to get the info i need. as the 'Site' a device is assigned to uses a different call.

geetanjalip
Level 1
Level 1

I would like to get the location information which will have latitude , longitude or x , y coordinates of the location. 

Also if I can retrieve floor maps using some API please let me know.

jonathanmoulton
Level 1
Level 1

I found a way to accomplish pulling the devices per site, and the site has all the location information needed. 

First we pull the site, general api call:
sitepull = '/dna/intent/api/v1/site'

Then we parse the list of sites and pull the membership per site

'/dna/intent/api/v1/membership/{}'.format(site['id'])

This returns the site general memberships and the devices associated with the site.

Hope this helps