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
This commit is contained in:
Tatiana Kholkina 2018-11-06 11:17:01 +03:00 committed by Tetiana Lashchova
parent a9393ef29a
commit e8c08e2abb
1 changed files with 5 additions and 9 deletions

View File

@ -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