Skip to content

Commit

Permalink
Fix broken solidfire create-snapshot
Browse files Browse the repository at this point in the history
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'].

Closes-Bug: 1234970

Change-Id: I50603b3ac43f2c3c7e7811ec34de078a268519f7
  • Loading branch information
j-griffith committed Oct 7, 2013
1 parent 19e92af commit 27e5674
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
53 changes: 53 additions & 0 deletions cinder/tests/test_solidfire.py
Expand Up @@ -23,6 +23,7 @@

from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import test
from cinder.volume import configuration as conf
from cinder.volume.drivers.solidfire import SolidFire
Expand Down Expand Up @@ -115,6 +116,9 @@ def fake_issue_api_request(obj, method, params):
'iqn': test_name}]}}
return result

elif method is 'CloneVolume':
return {'result': {'volumeID': 6}, 'id': 2}

else:
LOG.error('Crap, unimplemented API call in Fake:%s' % method)

Expand All @@ -135,6 +139,9 @@ def fake_volume_get(obj, key, default=None):
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(SolidFire, '_issue_api_request',
self.fake_issue_api_request)
Expand Down Expand Up @@ -162,6 +169,52 @@ def test_create_volume(self):
model_update = sfv.create_volume(testvol)
self.assertNotEqual(model_update, None)

def test_create_snapshot(self):
self.stubs.Set(SolidFire, '_issue_api_request',
self.fake_issue_api_request)
self.stubs.Set(SolidFire, '_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 = SolidFire(configuration=self.configuration)
model_update = sfv.create_volume(testvol)
sfv.create_snapshot(testsnap)

def test_create_clone(self):
self.stubs.Set(SolidFire, '_issue_api_request',
self.fake_issue_api_request)
self.stubs.Set(SolidFire, '_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 = SolidFire(configuration=self.configuration)
sfv.create_cloned_volume(testvol_b, testvol)

def test_create_volume_with_qos(self):
preset_qos = {}
preset_qos['qos'] = 'fast'
Expand Down
7 changes: 6 additions & 1 deletion cinder/volume/drivers/solidfire.py
Expand Up @@ -332,9 +332,14 @@ def _do_clone_volume(self, src_uuid, src_project_id, v_ref):
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)

Expand Down

0 comments on commit 27e5674

Please sign in to comment.