LXD container creation "hook"

Following my post here I have been trying to figure out a way to run nmap -sn NETWORK each time some Windows VM is created.

For context, on my LXD Server I have a container that’s running a modified version of LXDUI that amongst other things has VM support and installation inside container implemented. It communicates with the host as a remote LXD server to fetch all the data necessary.

In order for my Windows VMs IP to be shown however, I would need the host’s ARP cache to be updated automatically, which would mean running nmap or any form of network communication between the host and the newly created Windows VM to happen.

Does LXD’s API have any sort of “hook” implementation that runs a system call whenever some instance is created?

All help is appreciated.

The events socket could provide this

https://linuxcontainers.org/lxd/docs/master/rest-api#10events

Thank you, I will explore the API call to see how it works. I have found the pylxd documentation for it but have been unable to get any event output. I will look further into the matter and update any findings.