Does anyone here know how to add a device via rest API into Spectrum? Ideally, directly into a specified container.
What I'm trying to do is to find a replacement for Spectrum discovery via rest. Any suggestions or code examples are welcome.
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 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>
Hope this helps!
Thank you very much. I think this will help.
You are welcome!
I explained Container Structure creation here:
Otherwise if there's anything else, let me know!
You are referring to an action 0x25e0022 I cannot find in the Spectrum documentation.
Could you please tell us where you found it ?
I managed to find it either via communities or raising a ticket with support. If I am struggling with something and think that there should be a way to do something (that is in the gui) via REST I raise a support ticket and they provide them.
I used this below script .. (borrowed from this thread :) )
Got this as output: "0x1019d2"
then used this script: http://10.33.230.90/spectrum/restful/action/0x25e0022?mh=0x1019d2
got "succesfull" as output
But nothing seems to be coming on topology and spectrum landscape went to red after running this script, am doing this in soupui tool. as i dont have much knowledge on scripting.
When you say the landscape went red, do you mean the landscape died and you had to do a db restore and bring it up again? What version of Spectrum are you running?
No landscape didn't died , but was on red color with no events or alarms related to it . now devices are getting created , but some how it goes to lost and found tab .