From e8c08e2abbce8d9791024f46220e37b49381cd48 Mon Sep 17 00:00:00 2001 From: Tatiana Kholkina Date: Tue, 6 Nov 2018 11:17:01 +0300 Subject: [PATCH] Fix accessing to optional cinder pool attributes Leave storage pool arguments empty if they are not provided by cinderclient. Change-Id: I90435146b33465c8eef95a6104e53285f785b014 Closes-Bug: #1800468 --- watcher/decision_engine/model/collector/cinder.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/watcher/decision_engine/model/collector/cinder.py b/watcher/decision_engine/model/collector/cinder.py index eb644b1f1..c1fa508e4 100644 --- a/watcher/decision_engine/model/collector/cinder.py +++ b/watcher/decision_engine/model/collector/cinder.py @@ -230,21 +230,17 @@ class ModelBuilder(object): "free_capacity_gb", "provisioned_capacity_gb", "allocated_capacity_gb"] + node_attributes = {"name": pool.name} for attr in attrs: try: - int(getattr(pool, attr)) + node_attributes[attr] = int(getattr(pool, attr)) + except AttributeError: + LOG.debug("Attribute %s for pool %s is not provided", + attr, pool.name) except ValueError: raise exception.InvalidPoolAttributeValue( name=pool.name, attribute=attr) - node_attributes = { - "name": pool.name, - "total_volumes": pool.total_volumes, - "total_capacity_gb": pool.total_capacity_gb, - "free_capacity_gb": pool.free_capacity_gb, - "provisioned_capacity_gb": pool.provisioned_capacity_gb, - "allocated_capacity_gb": pool.allocated_capacity_gb} - storage_pool = element.Pool(**node_attributes) return storage_pool