From 5dbdb11e8d8659a6b823c9552052b443050886ca Mon Sep 17 00:00:00 2001 From: Zhiteng Huang Date: Sat, 2 Aug 2014 01:50:47 +0800 Subject: [PATCH] Fix solidfire accept_transfer Previous fix has a mistake which makes the situation worse. This change fix volume['project_id'] and volume['user_id'] and adds unit test for accept_transfer. Closes-bug: # 1349475 Change-Id: I7b2bcefa4c8d173689cc63ee5aa9e00397c7f8ca --- cinder/tests/test_solidfire.py | 18 +++++++++++++++--- cinder/volume/drivers/solidfire.py | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cinder/tests/test_solidfire.py b/cinder/tests/test_solidfire.py index 189e04b03..ec5126310 100644 --- a/cinder/tests/test_solidfire.py +++ b/cinder/tests/test_solidfire.py @@ -481,6 +481,21 @@ class SolidFireVolumeTestCase(test.TestCase): 'maxIOPS': 200, 'burstIOPS': 300}) + def test_accept_transfer(self): + sfv = SolidFireDriver(configuration=self.configuration) + self.stubs.Set(SolidFireDriver, '_issue_api_request', + self.fake_issue_api_request) + testvol = {'project_id': 'testprjid', + 'name': 'test_volume', + 'size': 1, + 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', + 'created_at': timeutils.utcnow()} + expected = {'provider_auth': 'CHAP cinder-new_project 123456789012'} + self.assertEqual(sfv.accept_transfer(self.ctxt, + testvol, + 'new_user', 'new_project'), + expected) + def test_retype(self): sfv = SolidFireDriver(configuration=self.configuration) self.stubs.Set(SolidFireDriver, '_issue_api_request', @@ -500,7 +515,6 @@ class SolidFireVolumeTestCase(test.TestCase): 'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66', 'created_at': timeutils.utcnow()} - sfv = SolidFireDriver(configuration=self.configuration) self.assertTrue(sfv.retype(self.ctxt, testvol, type_ref, diff, host)) @@ -520,8 +534,6 @@ class SolidFireVolumeTestCase(test.TestCase): 'maxIOPS': '2000', 'burstIOPS': '3000'}} - qos_specs - def _fake_get_volume_type(ctxt, type_id): return test_type diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 64c16e29e..ed21ddf88 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -770,8 +770,8 @@ class SolidFireDriver(SanISCSIDriver): if 'result' not in data: raise exception.SolidFireAPIDataException(data=data) - volume['project_id': new_project] - volume['user_id': new_user] + volume['project_id'] = new_project + volume['user_id'] = new_user model_update = self._do_export(volume) LOG.debug("Leaving SolidFire transfer volume") return model_update -- 2.45.2