Solved

API call to list all devices against a domain

  • 10 February 2022
  • 6 replies
  • 415 views

Hi,

Does anyone know how to use the API to return the name and ip address of all the devices held in the database for a single domain?

I have no problem using the API to connect, select the tenant & domain, and so on. 

I can see API calls for returning individual devices (if you provide the name and/or ip address).

But what if you want to return all of them.

For example:

Say my NetBrain has 500 devices against a domain. And I have another IP address source (my company’s single truth list), which has 480. 

I need to get the list of 500 to compare against the 480 so that I can delete the (now obsolete) 20.

Yes, I could manually do the deletion, but that is laborious.

regards

Declan  

icon

Best answer by declanw 3 March 2022, 12:27

View original

6 replies

Userlevel 4
Badge +1

Hi @declanw 
I do not think there is an API call to get all devices from a domain.

Workaround 1: put all devices of your domain into a Device Group and use the “Get Group Devices API” which will return all devices from your list. When using Dynamic Search for this group, the group can be updated in your daily benchmark.

Workaround 2: use the Inventory Report to create an inventory which you can export.

Thanks Carsten.

I will investigate the Group API. 

Dongxu Jia from the NetBrain Support team also responded :

According to your description, NetBrain currently does not provide a REST API to directly obtain all devices of the specified domain.

But NetBrain supports the RESTful API to get all devices of the specified Site.

If you have very few devices, you can get all the devices under My Network/, and if you have a lot of devices, you can get all the devices under the specified Site Path, and you can get them multiple times at the same time.”

Kind regards

Declan

 

 

Hi, I have my Python code doing what it needs to do.

In the end, I used the “looping around leaf Sites” solution. 

 I tried the Device Group and found that if it failed to add 1 device to a group, it did not any others. Probably my poor coding. 

Thanks for the guidance.

 

if you are looking for all records in the mongodb you can hit the shared device settings endpoint.  

https://github.com/NetBrainAPI/NetBrain-REST-API-R10.0a/blob/main/REST%20APIs%20Documentation/Shared%20Device%20Setting%20Management/Get%20shared%20device%20settings%20API.md

if you have more then 100 devices you will have to create logic to loop the call so you increase the record groups by 100 each time.  

Thanks to all that replied to this.

It is obvious that there are various ways to do it. In the end, I guess it is down to what works best for your environment.

Kind regards,

DeclanW 

If you use  /V1/CMDB/Devices with hostname and ip as “”, can’t we receive the entire device list of a domain.

Reply


Community |  Ideas

Facebook |  Instagram |  Youtube |  Twitter |  LinkedIn
Privacy & Security Statement  |  Terms & Conditions |  Impressum  |  UK Modern Slavery Statement