RFC: Add endpoint /discover
As previous work for https://gitlab.freedesktop.org/mupuf/valve-infra/-/issues/76 I'm adding a new endpoint and I'm asking here for comments about the new API. There are plenty of different ways to do this and I'm aiming to get one that will work with future changes.
This patchset is adding a new endpoint /discover that will be used to power on the differents port_id from a PDU.
The following request:
curl -X PUT HOST/api/v1/discovery \
-H 'Content-Type: application/json' \
-d '{ "state": "ON", "port_id": "8", "pdu": "VPDU"}'
will start a discovery process powering the port_id 8 in the pdu VPDU.
If the machine is powered on successfully, it'll add the data of the
on-going discovery to mars.discovery, a new dictionary discovery
inside the mars class that I have added.
If the request is made with a GET method:
curl -sL HOST/api/v1/discovery
the response will give the information of any discovery process ongoing and the data when it started or will be empty.
When adding a new machine after a boot, the code will check if this machine has been booted after a discovery process and in that case, add the information of the pdu and pdu_port_id to the machine information in marsdb.
Things can go wrong if after powering a port_id from the pdu, the machine behind it doesn't boot. In that case, this request will allow to erase the discovery data:
curl -sL HOST/api/v1/discovery/cancel