Running external "hooks" on different stages of node lifecycle

Hi,

I’m looking for a way to execute various hooks from maas that could be executed at different times of the node lifecycle.

Two examples that came to my mind right now are:

  1. When node is deployed and renamed, call external IPAM API to update node information
  2. (something I care about mode) A hook that can be executed before node is (re-)commissioned to reconfigure network switch and move the node to separate network. Same thing before the deployment, a way to call external endpoint to reconfigure switch ports to move node to a specified network.

Any ideas how could those be achieved? I went through the documentation, but other than running scripts from inside the commissioned/deployed server I couldn’t really find anything that would fit my usecase.