Commit 23f78cf7 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix division by zero

parent 3cd6c41f
......@@ -80,5 +80,8 @@ def vm_fits_in_backend(backend, vm):
def backend_score(backend, flavor):
mem_ratio = 1 - (backend.mfree / backend.mtotal) if backend.mtotal else 0
disk_ratio = 1 - (backend.dfree / backend.dtotal) if backend.dtotal else 0
cpu_ratio = ((backend.pinst_cnt + 1) * 4) / (backend.ctotal * 3)
if backend.ctotal:
cpu_ratio = ((backend.pinst_cnt + 1) * 4) / (backend.ctotal * 3)
else:
cpu_ratio = 1
return 0.5 * cpu_ratio + 0.5 * (mem_ratio + disk_ratio)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment