Page 1 of 1

Remote Managing WISP Switch

Posted: Sat Dec 24, 2016 5:12 pm
by spynappels
Hi guys,

I have a question around controlling a WISP switch remotely without using an interactive method like the WebUI or CLI manually.

Ideally I'd like to know if a (Token secured) API can be used to make configuration changes, rather than just polling for statuses.
Alternatively, if something like snmpset could be used, that would also be useful.

The settings I specifically want to change are POE states on individual ports, although some other settings would also be useful.

Thanks in advance,
Stefan

Re: Remote Managing WISP Switch

Posted: Mon Dec 26, 2016 12:35 pm
by Eric Stern
Most people just script the CLI over SSH. But you could also use the REST API to read/write the configuration if you wanted.

There is some information on how to use the REST API here: viewtopic.php?f=6&t=2216&p=15793

Once you get the session cookie you will want to GET /api/v1/config to obtain the configuration in JSON format. Modify the configuration as needed and then POST to /api/v1/config to save the new config on the switch and then POST (with an empty body) to /api/v1/apply to apply the new configuration.

Re: Remote Managing WISP Switch

Posted: Mon Dec 26, 2016 4:16 pm
by spynappels
Thanks for that Eric, I'll have to have a play with that and see what I can work out.

Re: Remote Managing WISP Switch

Posted: Wed Dec 28, 2016 3:38 pm
by spynappels
Thanks for your help so far Eric. I have now got the calls to login and get a PHPSESSID and can successfully query the API.

I'm using Python with the requests module and so far I've been able to do everything I needed to (eventually) except for saving a whole config back to the switch. I keep getting version mismatch 409 response codes, which I've found in the api.php and config.php files and which I'm now working out.

What I'm not 100% clear on from my reading of these 2 files is whether there may be a (supported) way to only change 1 setting using the POST config method. As far as I can tell there isn't, but in config.php I do see how the config.json is being built and populated and I think it may be possible to hack something together there, but I know that won't be supported, and I was hoping there might be an undocumented but supported way of doing the same thing.

Oh, and if you are looking to add to a wishlist, Token based auth for the API and documentation would be awesome. (as well as being able to edit individual settings by making API calls......)