Updated vm_mhz_to_percentage, return [0] if there are no VMs - the host is idle
This commit is contained in:
parent
222cb18e02
commit
ad07469551
@ -431,6 +431,9 @@ def vm_mhz_to_percentage(vm_mhz_history, host_mhz_history, physical_cpu_mhz):
|
||||
:return: The history of the host's CPU utilization in percentages.
|
||||
:rtype: list(float)
|
||||
"""
|
||||
if not vm_mhz_history:
|
||||
return [0.]
|
||||
|
||||
max_len = max(len(x) for x in vm_mhz_history)
|
||||
if len(host_mhz_history) > max_len:
|
||||
host_mhz_history = host_mhz_history[-max_len:]
|
||||
|
@ -196,3 +196,9 @@ class LocalManager(TestCase):
|
||||
3000),
|
||||
[0.1, 0.2, 0.2, 0.5])
|
||||
|
||||
self.assertEqual(manager.vm_mhz_to_percentage(
|
||||
[],
|
||||
[300, 0, 300, 0, 300],
|
||||
3000),
|
||||
[0.])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user