From 6c4837c79e6dadc1c7b4a6e64a558b7696609a9d Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Fri, 4 Mar 2016 15:02:53 +0100 Subject: [PATCH] Do not fail to calculate sto tags if storage is not updated --- cloudcontrol/node/hypervisor/lib.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudcontrol/node/hypervisor/lib.py b/cloudcontrol/node/hypervisor/lib.py index d9244b8..30a9a2f 100644 --- a/cloudcontrol/node/hypervisor/lib.py +++ b/cloudcontrol/node/hypervisor/lib.py @@ -326,13 +326,15 @@ class StorageIndex(object): Tag('sto%s_size' % s.name, partial(lambda x: x.capacity, s), 5, 5), Tag('sto%s_free' % s.name, partial(lambda x: x.available, s), 5, 5), Tag('sto%s_used' % s.name, - partial(lambda x: x.capacity - x.available, s), 5, 5), + partial(lambda x: x.capacity - x.available + if x.available is not None and x.capacity is not None else None, s), 5, 5), Tag('sto%s_type' % s.name, partial(lambda x: x.type, s), 5, 5), Tag('sto%s_vol' % s.name, partial(lambda x: ' '.join(x.volumes) if x.volumes and not x.is_shared else None, s), 5, 5), Tag('sto%s_ratio' % s.name, - partial(lambda x: '%0.2f' % (1 - float(x.available) / x.capacity), s), 5, 5), + partial(lambda x: '%0.2f' % (1 - float(x.available) / x.capacity) + if x.available is not None and x.capacity is not None else None, s), 5, 5), )) self.update_path_index() -- GitLab