[Users] Using python sdk to find the VMs running on a host.

Deepthi Dharwar deepthi at linux.vnet.ibm.com
Tue Jun 25 04:54:30 UTC 2013


Hi,

I am using the ovirt-python-sdk to figure out if the host is idle or
not. The way to determine if the host is idle at a given instant is
finding out the number of VMs running on it. If the number of VMs = 0
implies host is idle.

I was exploring the python sdk to figure out Host-VMs mapping i.e What
are the VMs running on the different host.

Looks like the only way to find this, is to query each VM in /api/vms
list to get the host on which it is running.

Is this the right way ? Is there no direct query or REST API to list
the VMs running on a given host at that instant.

I was looking to get the data center hierarchy structure.
Number_of_datacenters
      |
      V
clusters in each data center
      |
      V
Hosts in each cluster
      |
      V
 VMs on each host.

This kind of mapping as seen on the GUI. Is there any way to obtain
the same from the ovirt-python-sdk ?

With this information, this would help me write scripts to turn-off my
hosts if idle automatically and power them on as required.

Regards,
Deepthi






More information about the Users mailing list