How does foreman makes the decision on which server the vm is created?


we are using Foreman with Xen Orchestra to manage our infra. Right now we are creating our VMs through the GUI which does a good job. Now I was tasked to automate the process. While the api doc has (nearly) all the info, I could not find out how to decide where to put the new VM. We have multiple pools, the obvious choice is to place the new one on the least used pool for example. Inside the GUI the user has to select inside which pool to place the new VM. The VM seems to be then automagicaly placed on a server inside this pool. This is what my question is about: how does foreman makes this decision ?

The api seems to not expose resource usage information on any level, which does not seems to be exposed by Xen Orchestra either except on the host level. Using my knowledge it would mean that I am going to need check all hosts in all pools and compare the usage to make a decision.
Am I correct ? Does Foreman even makes this decision or is this actually made by Xen Orchestra itself ?

Should I find new info I will post it here. Thanks in advance.

Best regards.

Not sure if you mean storage pool. I do not know anyway, but here is the model implementation, you pass all the information through a hash called host compute attributes:

You can probably make some logging statements there, create it via UI to capture how it should look like and use that in API/hammer. That is what I can recommend.

Xen is not widely used in this community, your call might get no answer. Michael, the last maintainer, is no longer active here.