Fixed a bug in the global manager, when there is no data for new VMs

This commit is contained in:
Anton Beloglazov 2012-10-05 17:36:20 +10:00
parent dcd7576049
commit 465aaa9c4e

View File

@ -285,6 +285,13 @@ 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()
# 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
for host, vms in hosts_to_vms.items():
for i, vm in enumerate(vms):
if not vm in vms_last_cpu:
del hosts_to_vms[host][i]
hosts_cpu_usage = {}
hosts_ram_usage = {}
for host, vms in hosts_to_vms.items():
@ -478,6 +485,13 @@ def execute_overload(config, state, vm_uuids):
hosts_to_vms = vms_by_hosts(state['nova'], state['compute_hosts'])
vms_last_cpu = state['db'].select_last_cpu_mhz_for_vms()
# 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
for host, vms in hosts_to_vms.items():
for i, vm in enumerate(vms):
if not vm in vms_last_cpu:
del hosts_to_vms[host][i]
hosts_cpu_usage = {}
hosts_ram_usage = {}
inactive_hosts_cpu = {}