diff --git a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py index dd16eceee37..ec028497c4b 100644 --- a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py +++ b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py @@ -27,6 +27,7 @@ from cinder import exception from cinder.objects import fields from cinder import test from cinder.tests.unit.image import fake as fake_image +from cinder.tests.unit import utils as test_utils from cinder.volume import configuration as conf from cinder.volume.drivers import solidfire from cinder.volume import qos_specs @@ -517,15 +518,13 @@ class SolidFireVolumeTestCase(test.TestCase): def test_delete_volume(self): vol_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66' - testvol = {'project_id': 'testprjid', - 'name': 'test_volume', - 'size': 1, - 'id': vol_id, - 'name_id': vol_id, - 'created_at': timeutils.utcnow(), - 'provider_id': '1 5 None', - 'multiattach': True - } + testvol = test_utils.create_volume( + self.ctxt, + id=vol_id, + display_name='test_volume', + provider_id='1 5 None', + multiattach=True) + fake_sfaccounts = [{'accountID': 5, 'name': 'testprjid', 'targetSecret': 'shhhh', @@ -566,13 +565,7 @@ class SolidFireVolumeTestCase(test.TestCase): 'targetSecret': 'shhhh', 'username': 'john-wayne'}] fake_no_volumes = [] - vol_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66' - testvol = {'project_id': 'testprjid', - 'name': 'no-name', - 'size': 1, - 'id': vol_id, - 'name_id': vol_id, - 'created_at': timeutils.utcnow()} + testvol = test_utils.create_volume(self.ctxt) sfv = solidfire.SolidFireDriver(configuration=self.configuration) with mock.patch.object(sfv, @@ -589,14 +582,12 @@ class SolidFireVolumeTestCase(test.TestCase): 'targetSecret': 'shhhh', 'username': 'john-wayne'}] fake_no_volumes = [] - snap_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66' - testsnap = {'project_id': 'testprjid', - 'name': 'no-name', - 'size': 1, - 'id': snap_id, - 'name_id': snap_id, - 'volume_id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66', - 'created_at': timeutils.utcnow()} + testvol = test_utils.create_volume( + self.ctxt, + volume_id='b831c4d1-d1f0-11e1-9b23-0800200c9a66') + testsnap = test_utils.create_snapshot( + self.ctxt, + volume_id=testvol.id) sfv = solidfire.SolidFireDriver(configuration=self.configuration) with mock.patch.object(sfv, diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 5793e81f0cb..b432c613c4e 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -1437,7 +1437,12 @@ class SolidFireDriver(san.SanISCSIDriver): for acc in accounts: vols = self._get_volumes_for_account(acc['accountID'], - volume['name_id']) + volume.name_id) + # Check for migration magic here + if (not vols and (volume.name_id != volume.id)): + vols = self._get_volumes_for_account(acc['accountID'], + volume.id) + if vols: sf_vol = vols[0] break @@ -1488,9 +1493,9 @@ class SolidFireDriver(san.SanISCSIDriver): params, version='6.0') return - # Make sure it's not "old style" using clones as snaps - LOG.debug("Snapshot not found, checking old style clones.") - self.delete_volume(snapshot) + LOG.warning( + "Snapshot %s not found, old style clones may not be deleted.", + snapshot.id) def create_snapshot(self, snapshot): sfaccount = self._get_sfaccount(snapshot['project_id'])