From 58bf5d005394d2b31bab9e8971e765c35974ca07 Mon Sep 17 00:00:00 2001 From: int32bit Date: Sun, 11 Dec 2016 15:08:45 +0800 Subject: [PATCH] Fix error if free_disk_gb is None in CellStateManager The field 'free_disk_gb' in Objects.ComputeNode can be nullable. In CellStateManager._get_compute_hosts, we compute free_disk_mb by 'free_disk_gb * 1024'. If the free_disk_gb is None, it will raise a TypeError exception because None type can't multiply by an integer. We should check this value, and if it's None, we just let it return zero. Closes-Bug: #1648983 Change-Id: I558d544ff838807c1d605cb5ed8d0e0fa97ab00e --- nova/cells/state.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nova/cells/state.py b/nova/cells/state.py index a26c2417a75..eab5c6dd080 100644 --- a/nova/cells/state.py +++ b/nova/cells/state.py @@ -276,11 +276,9 @@ def _get_compute_hosts(): chost = compute_hosts[host] chost['free_ram_mb'] += max(0, compute.free_ram_mb) - free_disk = compute.free_disk_gb * 1024 - chost['free_disk_mb'] += max(0, free_disk) + chost['free_disk_mb'] += max(0, compute.free_disk_gb) * 1024 chost['total_ram_mb'] += max(0, compute.memory_mb) - total_disk = compute.local_gb * 1024 - chost['total_disk_mb'] += max(0, total_disk) + chost['total_disk_mb'] += max(0, compute.local_gb) * 1024 _get_compute_hosts() if not compute_hosts: