How to Use Spectrum REST API to Discover Devices
Release : 20.2.x
Component : SPCAPP: Spectrum Applications
You would need to first find the model handle of the parent container (of type Network) and then use one of the below REST calls :
For the model Handle, you either need to search for the container which contains the device, and get the model handle there, or when you create a container it returns the model handle in the response.
You can specify the model handle of the "Universe" from Topology.
You need to use different attributes for SNMP or ICMP:
For SNMP devices:
http://<SERVER>:<PORT>/spectrum/restful/model?landscapeid=<LANDSCAPE HANDLE>&attr=0x1006e&val=<DEVICE NAME>&ipaddress=<IP ADDRESS>&port=161&commstring=%23v2%2f<SNMP COMMUNITY>&retry=1&timeout=1000&parentmh=<PARENT MODEL HANDLE>
Just a note, the example shows SNMPv2, if you want to use SNMPv1 you need to remove the '%23v2%2f' - this is the URL friendly '# v 2 /'. There are some characters which you need to convert to HTML friendly codes: e.g.: '<space>' becomes '%20' etc.
For ICMP devices:
http://<SERVER>:<PORT>/spectrum/restful/model?landscapeid=<LANDSCAPE HANDLE>&attr=0x1006e&val=<DEVICE NAME>&attr=0x12d7f&val=<IP ADDRESS>&mtypehandle=0x10001&mtypeid=0x10290&attr=0x1000e&val=7&retry=1&timeout=1000&parentmh=<PARENT MODEL HANDLE>
Note we also set the 'Value_When_Red" so it creates alarms instead of just staying in INITIAL mode for pingable models.
This will add the device, you will still need to send a 'discover connections' action to the device after discovering. This can sometimes time out and you can only run one at a time, so you need to have a script which manages the discover connections. This will error mention that another discover is in progress which you can check for (text to check for is 'Another discovery process is currently in progress.')
URL: http://<SERVER>:<PORT>/spectrum/restful/action/0x25e0022?mh=<MODEL HANDLE>