RPI power management in MAAS with MAAS's Webhook and Node-RED controlled PoE managed switch
MAAS work by managing machines with netboot, and in order for machines to perform netboot any time MAAS needed. It need to be able to control the power state of the machines. MAAS support a wide ranges of power control types: such as Intelligent Platform Management Interface (IPMI) which support by machine's Baseboard management controller (BMC). However, the RPI does not come with such feature. Though, in order to allow MAAS to managed power cycle of the RPI, additional setup is required.
MAAS have a webhook that we can configure to run when MAAS need to power the machine as well as when it want to query the power status of the machines. And our managed PoE switch has the HTTP API server to manage the setting of the switch. However, since the two aren't compatible we have create a Node-RED flow that will transform the request from MAAS to the PoE switch.
To support PoE, we install the PoE hat on our RPi devices. We are using the PoE hat from here: https://thepihut.com/products/raspberry-pi-poe-plus-hat
We use the TL-SG108PE switch from TP-link https://www.tp-link.com/uk/business-networking/easy-smart-switch/tl-sg108pe/ because it have the smart confige feature. Unfortunately, our version does not have direct PoE power configuration option and we have to use the PoE auto recovery feature instead.
Create PoE control API with Node-RED
MAAS will send HTTP POST request with Power on/off request. and HTTP GET request when querying power status. We use Node-RED "http in" node to capture HTTP requests and "exec" node to run curl command to send API request to PoE switch.
The Node-RED flow JSON export is available here: rpi-poe-node-red-flow.json
Configure machine power with MAAS webhook
Once, we have deployed Node-RED flow, MAAS shuold be able to send request to it. We can go to MAAS, and configure the machine to use the webhook power control.