From a9be9c9735a07db163e843222cae9075864e1ef0 Mon Sep 17 00:00:00 2001 From: Tom Swanson Date: Tue, 2 Jun 2015 14:20:55 -0500 Subject: [PATCH] Dell SC: update_volume_stats could use uninitialized vars In _update_volume_stats in dell_storagecenter_common.py totalcapacitygb and freespacegb are not necessarily initialized in the LOG.debug call. Changed to data['total_capacity_gb'] and data['free_capacity_gb']. Also initialized to total_capacity_gb and free_capacity_gb dict entries to 'unavailable' which allowed the removal of two conditionals in the same function. Change-Id: Ib699e0d1cf67645298628aa96656888193843509 Closes-Bug: #1461230 --- .../volume/drivers/dell/dell_storagecenter_common.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cinder/volume/drivers/dell/dell_storagecenter_common.py b/cinder/volume/drivers/dell/dell_storagecenter_common.py index d44eeab0a..dd7551645 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_common.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_common.py @@ -307,6 +307,8 @@ class DellCommonDriver(san.SanDriver): data['driver_version'] = self.VERSION data['storage_protocol'] = 'iSCSI' data['reserved_percentage'] = 0 + data['free_capacity_gb'] = 'unavailable' + data['total_capacity_gb'] = 'unavailable' # In theory if storageusage is None then we should have # blown up getting it. If not just report unavailable. if storageusage is not None: @@ -316,15 +318,11 @@ class DellCommonDriver(san.SanDriver): freespace = storageusage.get('freeSpace') freespacegb = self._bytes_to_gb(freespace) data['free_capacity_gb'] = freespacegb - if data.get('total_capacity_gb') is None: - data['total_capacity_gb'] = 'unavailable' - if data.get('free_capacity_gb') is None: - data['free_capacity_gb'] = 'unavailable' data['QoS_support'] = False self._stats = data LOG.debug('Total cap %(t)s Free cap %(f)s', - {'t': totalcapacitygb, - 'f': freespacegb}) + {'t': data['total_capacity_gb'], + 'f': data['free_capacity_gb']}) def update_migrated_volume(self, ctxt, volume, new_volume): """Return model update for migrated volume. -- 2.45.2