def _get_host_utilization(context, host, ram_mb, disk_gb):
 instances = instance_get_all_by_host(context, host)
 vms = len(instances)
 free_ram_mb = (ram_mb - FLAGS.reserved_host_memory_mb)
 free_disk_gb = (disk_gb - (FLAGS.reserved_host_disk_mb * 1024))
 work = 0
 for instance in instances:
  free_ram_mb -= instance.memory_mb
  free_disk_gb -= instance.root_gb
  free_disk_gb -= instance.ephemeral_gb
  if (instance.vm_state in [vm_states.BUILDING, vm_states.REBUILDING, vm_states.MIGRATING, vm_states.RESIZING]):
   work += 1
 return dict(free_ram_mb=free_ram_mb, free_disk_gb=free_disk_gb, current_workload=work, running_vms=vms)

def _get_host_utilization ( context , host , ram_mb , disk_gb ) : instances = instance_get_all_by_host ( context , host ) vms = len ( instances ) free_ram_mb = ( ram_mb - FLAGS . reserved_host_memory_mb ) free_disk_gb = ( disk_gb - ( FLAGS . reserved_host_disk_mb * 1024 ) ) work = 0 for instance in instances : free_ram_mb -= instance . memory_mb free_disk_gb -= instance . root_gb free_disk_gb -= instance . ephemeral_gb if ( instance . vm_state in [ vm_states . BUILDING , vm_states . REBUILDING , vm_states . MIGRATING , vm_states . RESIZING ] ) : work += 1 return dict ( free_ram_mb = free_ram_mb , free_disk_gb = free_disk_gb , current_workload = work , running_vms = vms )
compute the current utilization of a given host .