How to query the Opennebula Scheduler whether there are sufficient resources (CPU and Memory) to launch a VM?

I am using Opennebula to manage KVM hosts. When I try to launch a VM, if there are not enough resources (CPU or Memory) in the hosts, the VM will stay in Pending mode forever.

Is there any way that I can programmatically query the Opennebula Scheduler whether there are sufficient resources to launch the VM? If there are not enough resources, I would like to stop the launch VM operation and inform the users.

By the way, I found that sometimes the Opennebula Scheduler will not launch a VM in a host even though there are sufficient resources in the host. For example, in a host with 4 cores and 16GB RAM, 3 cores and 14GB RAM are in use. When I try to launch a new VM with 1 core and 2GB RAM; or 1 core and 1GB RAM; or 0.5 core and 1GB RAM, the VM will stay in pending mode forever. May I know how can I use all the resources in the host for VM?

Is there any way that I can programmatically query the Opennebula Scheduler whether there are sufficient resources to launch the VM? If there are not enough resources, I would like to stop the launch VM operation and inform the users.

We don’t have a way to query the scheduler. But please open a feature request with your use case and we’ll consider it. Our dev portal is http://dev.opennebula.org/

By the way, I found that sometimes the Opennebula Scheduler will not launch a VM in a host even though there are sufficient resources in the host. For example, in a host with 4 cores and 16GB RAM, 3 cores and 14GB RAM are in use. When I try to launch a new VM with 1 core and 2GB RAM; or 1 core and 1GB RAM; or 0.5 core and 1GB RAM, the VM will stay in pending mode forever. May I know how can I use all the resources in the host for VM?

Are you using the RESERVED_* host attributes?
What you can do is enable more detail in the scheduler logs. Set the debug_level to 5 (DDDEBUG) in /etc/one/sched.conf and restart the opennebula service. The /var/log/one/sched.log file now should have much more detailed info about the decision to leave the vm in pending.

Related? Scheduler doesn't go through all hosts