iPXE discussion forum
About WebAPI, JSON - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: About WebAPI, JSON (/showthread.php?tid=10324)



About WebAPI, JSON - BloodFox - 2017-09-26 03:36

Hi guys, Can you consider increasing support for the WEB API and JSON?
iPXE is a great tool, if you can support WEBAPI, its ability will be greatly enhanced.

Thank you for bringing so easy to use tools!


RE: About WebAPI, JSON - NiKiZe - 2017-09-26 06:43

What kind of API, why, and what would it be used for?


RE: About WebAPI, JSON - BloodFox - 2017-09-26 08:22

(2017-09-26 06:43)NiKiZe Wrote:  What kind of API, why, and what would it be used for?

WebAPI can use in iPXE script to get some data from web api server.

for example, the command "webapi" is new command:
webapi <setting> <web api address>

script:
Code:
webapi iscsiaddress http://api.example.com/GetiSCSIAddress/${net0/ip}
sanhook ${iscsiaddress}



RE: About WebAPI, JSON - mcb30 - 2017-09-26 12:02

(2017-09-26 08:22)BloodFox Wrote:  
Code:
webapi iscsiaddress http://api.example.com/GetiSCSIAddress/${net0/ip}
sanhook ${iscsiaddress}

You can already achieve this; simply have your web server return a trivial iPXE script such as:

Code:
#!ipxe
set iscsiaddress iscsi:192.168.0.1::::iqn.1992-01.com.example.target

Michael


RE: About WebAPI, JSON - NiKiZe - 2017-09-26 21:10

As Michael wrote, just return a script,
If you want a script that just sets options for you do this:

Code:
chain http://api.example.com/GetiSCSIAddress/${net0/ip}
sanhook ${iscsiaddress}

Where that endpoint simply returns
Code:
#!ipxe
set iscsiaddress iscsi:192.168.0.1::::iqn.1992-01.com.example.target

Just have your api check for the ipxe user-agent

I'm using this on http://b800.org to make it easy to type by hand if need be.
Code:
chain http://b800.org/

You can force the same output as is given to iPXE as user-agent by visiting: http://b800.org/?ipxe=1