]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes total_capacity_gb value in CloudByte driver.
authoryogeshprasad <yogesh.prasad@cloudbyte.com>
Wed, 11 Feb 2015 13:52:33 +0000 (19:22 +0530)
committeryogeshprasad <yogesh.prasad@cloudbyte.com>
Thu, 12 Feb 2015 06:55:21 +0000 (12:25 +0530)
CloudByte storage returns total capacity value in two formats. One is
numeric and the other is alphanumeric.

Previously data['total_capacity_gb'] was referring the alphanumeric value
& now it is referring to the correct numeric value.

In addition, changes were made to test_cloudbyte.py to unit test
free_capacity_gb and total_capacity_gb.

Closes-Bug: 1420746

Change-Id: I601c2a78c1727bc815771ca26aea928fa2887d09

cinder/tests/test_cloudbyte.py
cinder/volume/drivers/cloudbyte/cloudbyte.py

index 1e7855fe537fd609b20352b0660629599ed13b43..6c183b31ee8ef9b3900996d976dc63101cb4411b 100644 (file)
@@ -637,7 +637,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
         self.driver = CloudByteISCSIDriver(configuration=configuration)
 
         # override some parts of driver configuration
-        self.driver.configuration.tsm_name = 'openstack'
+        self.driver.configuration.cb_tsm_name = 'openstack'
         self.driver.configuration.cb_account_name = 'CustomerA'
 
     def _side_effect_api_req(self, cmd, params, version='1.0'):
@@ -930,7 +930,7 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
 
         # assert equality checks for certain configuration attributes
         self.assertEqual(
-            'openstack', self.driver.configuration.tsm_name)
+            'openstack', self.driver.configuration.cb_tsm_name)
         self.assertEqual(
             'CustomerA', self.driver.configuration.cb_account_name)
         self.assertThat(
@@ -1179,6 +1179,8 @@ class CloudByteISCSIDriverTestCase(testtools.TestCase):
         self.assertEqual(1, mock_api_req.call_count)
 
         # assert the result attributes with respective values
+        self.assertEqual(1024.0, vol_stats['total_capacity_gb'])
+        self.assertEqual(824.0, vol_stats['free_capacity_gb'])
         self.assertEqual(0, vol_stats['reserved_percentage'])
         self.assertEqual('CloudByte', vol_stats['vendor_name'])
         self.assertEqual('iSCSI', vol_stats['storage_protocol'])
index c33b9df0a6594ad68627759348d7038d1dd6f1e0..7108747497631d4d042ad8db83b727615a02e509 100644 (file)
@@ -18,6 +18,7 @@ import json
 import time
 import urllib
 
+from oslo_utils import units
 import six
 
 from cinder import exception
@@ -563,22 +564,17 @@ class CloudByteISCSIDriver(san.SanISCSIDriver):
         for tsms in tsm_details:
             if tsms['name'] == tsmname:
                 flag = 1
-                storage_buckets = {}
-                storage_buckets = tsms['storageBuckets']
-                quota = 0
-                for bucket in storage_buckets:
-                    quota = bucket['quota']
-                    break
-
-                data['total_capacity_gb'] = quota
+                data['total_capacity_gb'] = (
+                    float(tsms['numericquota']) / units.Ki)
                 data['free_capacity_gb'] = (
-                    int(tsms['availablequota']) / 1000)
+                    float(tsms['availablequota']) / units.Ki)
+                break
 
         # TSM not found in CloudByte storage
         if flag == 0:
             LOG.error(_LE("TSM [%s] not found in CloudByte storage."), tsmname)
-            data['total_capacity_gb'] = 0
-            data['free_capacity_gb'] = 0
+            data['total_capacity_gb'] = 0.0
+            data['free_capacity_gb'] = 0.0
 
         return data