SolidFire driver should return ceiling of volume size

The function manage_existing_get_size returns the floor of volume size
in solidfire driver. But in the driver API:"When calculating the size,
round up to the next GB." The solidFire driver should be consistent
with the driver API. This patch fixes it by returning the ceiling of
volume size.

Change-Id: Icc4f893b9e18dc525b85b45f3307663b6d8884ed
Closes-Bug: #1586306
This commit is contained in:
yuyafei 2016-06-08 09:36:49 +08:00
parent 42db20e90a
commit f14aace2c2
2 changed files with 16 additions and 2 deletions

View File

@ -186,7 +186,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'name': test_name,
'accountID': 8,
'sliceCount': 1,
'totalSize': 1 * units.Gi,
'totalSize': int(1.75 * units.Gi),
'enable512e': True,
'access': "readWrite",
'status': "active",
@ -816,6 +816,20 @@ class SolidFireVolumeTestCase(test.TestCase):
self.assertIsNotNone(model_update)
self.assertIsNone(model_update.get('provider_geometry', None))
def test_manage_existing_get_size(self):
external_ref = {'name': 'existing volume', 'source-id': 5}
testvol = {'project_id': 'testprjid',
'name': 'testvol',
'size': 1,
'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
'created_at': timeutils.utcnow()}
mock_issue_api_request = self.mock_object(solidfire.SolidFireDriver,
'_issue_api_request')
mock_issue_api_request.side_effect = self.fake_issue_api_request
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
size = sfv.manage_existing_get_size(testvol, external_ref)
self.assertEqual(2, size)
@mock.patch.object(solidfire.SolidFireDriver, '_issue_api_request')
@mock.patch.object(solidfire.SolidFireDriver, '_create_template_account')
def test_create_volume_for_migration(self,

View File

@ -1827,7 +1827,7 @@ class SolidFireDriver(san.SanISCSIDriver):
'limit': 1}
vols = self._issue_api_request(
'ListActiveVolumes', params)['result']['volumes']
return int(vols[0]['totalSize']) / int(units.Gi)
return int(math.ceil(float(vols[0]['totalSize']) / units.Gi))
def unmanage(self, volume):
"""Mark SolidFire Volume as unmanaged (export from Cinder)."""