Forum Discussion

Sean's avatar
5 years ago

Bulk add devices to device Group

We have up to 500 devices that need to be added to a LM device group via the API - is it possible to do this in bulk, with a single API call, or do we need to make an API call per device to set the group? We'll also need to be able to remove multiple devices in future, so the same question applies for removal.

I was hoping there may be a public 'Devices' property available on a device group, that would allow us to 'PUT' a device list to add/remove members, but I'm not able to find anything so far in the documentation.

Thanks in advance,


2 Replies

Replies have been turned off for this discussion
  • Assuming the devices are already in LM, I don't believe so. I'm pretty sure static groups are only assigned by in the Device API and not in the Device Group. But it should be pretty easy to throw a FOR loop around the API call and run 500 API calls pretty quickly. You may need to put a few small pauses in there because I think the API Rate cap is something like 400 calls/minute (the API will let you know).

    You might want to also look at Dynamic Groups, they let you auto assign devices automatically based on a AppliesTo filter. This would be just one API call (or one GUI change really) at the Device Group level. But this is really meant for grouping devices based on some common factor they share. I wouldn't suggest attempting to just create a huge AppliesTo full of hard coded names.

    If the devices are not in LM at all yet, then you can look at NetScan to add them. For example the CSV import will let you add devices and provide a hostgroup where the device should be added. Doesn't help for removing them from the group later though.

  • If there's a way to identify the ones you want moved separate from the ones you don't, you can use a property source with a REST API payload to do the dirty work for you.  I'm doing this with my Failover Cluster Grouping script elsewhere on the forum.  Feel free to pick apart what I'm doing there.  Note that the function for making the rest calls doesn't have a queryParam variable passed into it.  I've since fixed the scripts I'm using going forward, but that one works as it is for me... so I'm not touching it ;)