Updated the global manager to use the host CPU data

This commit is contained in:
Anton Beloglazov 2012-10-24 13:52:53 +11:00
parent 1ab44cc57e
commit 281e2fdf37

View File

@ -302,6 +302,7 @@ def execute_underload(config, state, host):
hosts_to_vms = vms_by_hosts(state['nova'], state['compute_hosts'])
vms_last_cpu = state['db'].select_last_cpu_mhz_for_vms()
hosts_last_cpu = state['db'].select_last_cpu_mhz_for_hosts()
# Remove VMs from hosts_to_vms that are not in vms_last_cpu
# These VMs are new and no data have been collected from them
@ -313,7 +314,8 @@ def execute_underload(config, state, host):
hosts_cpu_usage = {}
hosts_ram_usage = {}
for host, vms in hosts_to_vms.items():
host_cpu_mhz = sum(vms_last_cpu[x] for x in vms)
host_cpu_mhz = sum(vms_last_cpu[x] for x in vms) + \
hosts_last_cpu[host]
if host_cpu_mhz > 0:
hosts_cpu_usage[host] = host_cpu_mhz
hosts_ram_usage[host] = host_used_ram(state['nova'], host)