]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix broken solidfire create-snapshot
authorJohn Griffith <john.griffith@solidfire.com>
Thu, 3 Oct 2013 21:54:20 +0000 (15:54 -0600)
committerThierry Carrez <thierry@openstack.org>
Fri, 4 Oct 2013 07:46:33 +0000 (09:46 +0200)
A previous change to enable secifying size for cloned volumes
created introduced a bug that breaks the ability to create-snapshots
when using the SolidFire driver
(CID: I5628c7fa922780d6b0601e2daa79310a61085edc).

The problem is that we use a shared method in the SF driver for both
create-clone and create-snapshot, the added change only considers the
clone case and does a get ref['size'] but in the case of snapshots
this needs to be ref['volume_size'].

Change-Id: I50603b3ac43f2c3c7e7811ec34de078a268519f7
Closes-Bug: 1234970
(cherry picked from commit 3cd27defb1c820ceadd8bbc6bfd5a405a7376cdb)

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

index da011a9b0af8c27a30868e05c5498d76de00dab8..eefbfff09973c4b02a003860cdc983e7859a8141 100644 (file)
@@ -98,6 +98,12 @@ class SolidFireVolumeTestCase(test.TestCase):
             LOG.info('Called Fake ModifyVolume...')
             return {'result': {}, 'id': 1}
 
+        elif method is 'CloneVolume':
+            return {'result': {'volumeID': 6}, 'id': 2}
+
+        elif method is 'ModifyVolume':
+            return
+
         elif method is 'ListVolumesForAccount' and version == '1.0':
             test_name = 'OS-VOLID-a720b3c0-d1f0-11e1-9b23-0800200c9a66'
             LOG.info('Called Fake ListVolumesForAccount...')
@@ -135,6 +141,9 @@ class SolidFireVolumeTestCase(test.TestCase):
     def fake_update_cluster_status(self):
         return
 
+    def fake_get_model_info(self, account, vid):
+        return {'fake': 'fake-model'}
+
     def test_create_with_qos_type(self):
         self.stubs.Set(SolidFireDriver, '_issue_api_request',
                        self.fake_issue_api_request)
@@ -183,6 +192,52 @@ class SolidFireVolumeTestCase(test.TestCase):
                          '4096 4096')
         self.configuration.sf_emulate_512 = True
 
+    def test_create_snapshot(self):
+        self.stubs.Set(SolidFireDriver, '_issue_api_request',
+                       self.fake_issue_api_request)
+        self.stubs.Set(SolidFireDriver, '_get_model_info',
+                       self.fake_get_model_info)
+        testvol = {'project_id': 'testprjid',
+                   'name': 'testvol',
+                   'size': 1,
+                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+                   'volume_type_id': None,
+                   'created_at': timeutils.utcnow()}
+
+        testsnap = {'project_id': 'testprjid',
+                    'name': 'testvol',
+                    'volume_size': 1,
+                    'id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66',
+                    'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+                    'volume_type_id': None,
+                    'created_at': timeutils.utcnow()}
+
+        sfv = SolidFireDriver(configuration=self.configuration)
+        model_update = sfv.create_volume(testvol)
+        sfv.create_snapshot(testsnap)
+
+    def test_create_clone(self):
+        self.stubs.Set(SolidFireDriver, '_issue_api_request',
+                       self.fake_issue_api_request)
+        self.stubs.Set(SolidFireDriver, '_get_model_info',
+                       self.fake_get_model_info)
+        testvol = {'project_id': 'testprjid',
+                   'name': 'testvol',
+                   'size': 1,
+                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
+                   'volume_type_id': None,
+                   'created_at': timeutils.utcnow()}
+
+        testvol_b = {'project_id': 'testprjid',
+                     'name': 'testvol',
+                     'size': 1,
+                     'id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66',
+                     'volume_type_id': None,
+                     'created_at': timeutils.utcnow()}
+
+        sfv = SolidFireDriver(configuration=self.configuration)
+        sfv.create_cloned_volume(testvol_b, testvol)
+
     def test_initialize_connector_with_blocksizes(self):
         connector = {'initiator': 'iqn.2012-07.org.fake:01'}
         testvol = {'project_id': 'testprjid',
index 8b3c5b2f7f8a0bf93e8a20f76379ee204332405b..cbe09c11bbbe65f913371a565ef2d1c7bab6e6a1 100644 (file)
@@ -347,9 +347,14 @@ class SolidFireDriver(SanISCSIDriver):
         if src_project_id != v_ref['project_id']:
             sfaccount = self._create_sfaccount(v_ref['project_id'])
 
+        if v_ref.get('size', None):
+            new_size = v_ref['size']
+        else:
+            new_size = v_ref['volume_size']
+
         params = {'volumeID': int(sf_vol['volumeID']),
                   'name': 'UUID-%s' % v_ref['id'],
-                  'newSize': int(v_ref['size'] * self.GB),
+                  'newSize': int(new_size * self.GB),
                   'newAccountID': sfaccount['accountID']}
         data = self._issue_api_request('CloneVolume', params)