OPNsense Forum
English Forums => General Discussion => Topic started by: pear on February 03, 2019, 02:45:52 pm
-
hello
please can someone help me with WOL API?
i am able to wake all already defined computers at once with "wakeall" but i have no idea how to wake just one computer from list or with manually defined interface and mac
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/wakeall"
with getHost i can see from output that correct interface is selected with defined mac and description
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/getHost/$uuid"
getHost output:
....."lan":{"value":"correct interface name","selected":1}....."mac":"correct mac","descr":"my description"}}
many thanks
-
see
https://github.com/opnsense/plugins/blob/9e45c51384e276a785ac09502e10f7faf20739c9/net/wol/src/opnsense/mvc/app/views/OPNsense/Wol/index.volt#L63 (https://github.com/opnsense/plugins/blob/9e45c51384e276a785ac09502e10f7faf20739c9/net/wol/src/opnsense/mvc/app/views/OPNsense/Wol/index.volt#L63)
try the "set" command and probably pass uuid either in GET or the JSON body.
didn't test, i'm on a different mission.
m
-
#Will trigger an existing uuid:
POST /wol/wol/set {uuid: 6def5e9b-ebb5-409d-ab52-912c06be7dc2}
#Will trigger a manual/undefined wake:
POST /wol/wol/set {wake: {interface: "opt22", mac: "b4:2e:99:30:da:dd"}}
#Will add a new host to the list:
POST /wol/wol/addHost {host: {interface: "opt22", mac: "b4:2e:99:30:da:dd", descr: "My Hamster"}}
The stuff in brackets is the body of the post, a json encoded object (not array).
So except the basic auth, and the endpoint (ie. "/wol/wol/set"), all variables seem to be going into the body.
It is easy to sniff into the structure via browser dev tools. Some things are more structured than the DOCS show.
-
It's been a while since this thread but in case anyone stumbles across it: https://gist.github.com/derhelge/1ce6d31f106beea37dfcb36591ac63a7 There is a small Powershell script. We use it to be able to continue using WOL via SCCM / configmgr.