From: Mathieu Gagné Date: Tue, 9 Jul 2013 18:11:18 +0000 (-0400) Subject: Implement extend volume functionality in SolidFire X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3ecc2b4a0f1fcdea7160264e95e699cf55c55050;p=openstack-build%2Fcinder-build.git Implement extend volume functionality in SolidFire This implements the extend volume functionality for SolidFire driver. Implements: blueprint solidfire-extend-size-support Change-Id: I00dc15f722c70b8835ae5a060ca8f0c4a80a1acb --- diff --git a/cinder/tests/test_solidfire.py b/cinder/tests/test_solidfire.py index bb2bc06e6..bc7b16bb7 100644 --- a/cinder/tests/test_solidfire.py +++ b/cinder/tests/test_solidfire.py @@ -97,6 +97,10 @@ class SolidFireVolumeTestCase(test.TestCase): LOG.info('Called Fake DeleteVolume...') return {'result': {}, 'id': 1} + elif method is 'ModifyVolume' and version == '5.0': + LOG.info('Called Fake ModifyVolume...') + return {'result': {}, 'id': 1} + elif method is 'ListVolumesForAccount' and version == '1.0': test_name = 'OS-VOLID-a720b3c0-d1f0-11e1-9b23-0800200c9a66' LOG.info('Called Fake ListVolumesForAccount...') @@ -280,3 +284,41 @@ class SolidFireVolumeTestCase(test.TestCase): sfv = SolidFire(configuration=self.configuration) self.assertRaises(exception.SolidFireAPIException, sfv._get_cluster_info) + + def test_extend_volume(self): + self.stubs.Set(SolidFire, '_issue_api_request', + self.fake_issue_api_request) + testvol = {'project_id': 'testprjid', + 'name': 'test_volume', + 'size': 1, + 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} + sfv = SolidFire(configuration=self.configuration) + sfv.extend_volume(testvol, 2) + + def test_extend_volume_fails_no_volume(self): + self.stubs.Set(SolidFire, '_issue_api_request', + self.fake_issue_api_request) + testvol = {'project_id': 'testprjid', + 'name': 'no-name', + 'size': 1, + 'id': 'not-found'} + sfv = SolidFire(configuration=self.configuration) + self.assertRaises(exception.VolumeNotFound, + sfv.extend_volume, + testvol, 2) + + def test_extend_volume_fails_account_lookup(self): + # NOTE(JDG) This test just fakes update_cluster_status + # this is intentional for this test + self.stubs.Set(SolidFire, '_update_cluster_status', + self.fake_update_cluster_status) + self.stubs.Set(SolidFire, '_issue_api_request', + self.fake_issue_api_request_fails) + testvol = {'project_id': 'testprjid', + 'name': 'no-name', + 'size': 1, + 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} + sfv = SolidFire(configuration=self.configuration) + self.assertRaises(exception.SfAccountNotFound, + sfv.extend_volume, + testvol, 2) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 4b9385b1b..b0376e7f1 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -581,6 +581,32 @@ class SolidFire(SanISCSIDriver): return self.cluster_stats + def extend_volume(self, volume, new_size): + """Extend an existing volume.""" + LOG.debug(_("Entering SolidFire extend_volume...")) + + sfaccount = self._get_sfaccount(volume['project_id']) + params = {'accountID': sfaccount['accountID']} + + sf_vol = self._get_sf_volume(volume['id'], params) + + if sf_vol is None: + LOG.error(_("Volume ID %s was not found on " + "the SolidFire Cluster!"), volume['id']) + raise exception.VolumeNotFound(volume_id=volume['id']) + + params = { + 'volumeID': sf_vol['volumeID'], + 'totalSize': int(new_size * self.GB) + } + data = self._issue_api_request('ModifyVolume', + params, version='5.0') + + if 'result' not in data: + raise exception.SolidFireAPIDataException(data=data) + + LOG.debug(_("Leaving SolidFire extend_volume")) + def _update_cluster_status(self): """Retrieve status info for the Cluster."""