]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Implement extend volume functionality in SolidFire
authorMathieu Gagné <mgagne@iweb.com>
Tue, 9 Jul 2013 18:11:18 +0000 (14:11 -0400)
committerMathieu Gagné <mgagne@iweb.com>
Wed, 10 Jul 2013 15:22:02 +0000 (11:22 -0400)
This implements the extend volume functionality for SolidFire driver.

Implements: blueprint solidfire-extend-size-support

Change-Id: I00dc15f722c70b8835ae5a060ca8f0c4a80a1acb

cinder/tests/test_solidfire.py
cinder/volume/drivers/solidfire.py

index bb2bc06e6502edd550221d5531bc0201ee3a8f47..bc7b16bb747ed686c43b811903a9efff8cbbc15e 100644 (file)
@@ -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)
index 4b9385b1b76d05fb3d6d747f17ff4d7b0999fcea..b0376e7f144875fd5be08a9d65e4633929925ec9 100644 (file)
@@ -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."""