]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Dell SC: update_volume_stats could use uninitialized vars
authorTom Swanson <tom_swanson@dell.com>
Tue, 2 Jun 2015 19:20:55 +0000 (14:20 -0500)
committerTom Swanson <tom_swanson@dell.com>
Tue, 2 Jun 2015 21:58:18 +0000 (16:58 -0500)
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

cinder/volume/drivers/dell/dell_storagecenter_common.py

index d44eeab0ad681f48213f474ccf620d2021f55e48..dd7551645fe6a400904196ef1c00b785582c2fb9 100644 (file)
@@ -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.