From: Mathieu Gagné Date: Tue, 9 Jul 2013 01:11:59 +0000 (-0400) Subject: Add ability to specify SolidFire API version X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7497e40dce59cfc66e2d1ce7468843bc7949c770;p=openstack-build%2Fcinder-build.git Add ability to specify SolidFire API version This change is required for future works in the SolidFire driver. New SolidFire features (such as extend) are only available in the latest version of the SolidFire API. Default to '1.0' for backward compatibility. SolidFire still supports the '1.0' version in its latest release. Change-Id: I93590ab297d746d65a58f9166d160d0c1d833014 --- diff --git a/cinder/tests/test_solidfire.py b/cinder/tests/test_solidfire.py index 8679f4142..bb2bc06e6 100644 --- a/cinder/tests/test_solidfire.py +++ b/cinder/tests/test_solidfire.py @@ -50,10 +50,9 @@ class SolidFireVolumeTestCase(test.TestCase): self.stubs.Set(SolidFire, '_issue_api_request', self.fake_issue_api_request) - def fake_issue_api_request(obj, method, params): - if method is 'GetClusterCapacity': + def fake_issue_api_request(obj, method, params, version='1.0'): + if method is 'GetClusterCapacity' and version == '1.0': LOG.info('Called Fake GetClusterCapacity...') - data = {} data = {'result': {'clusterCapacity': {'maxProvisionedSpace': 99999999, 'usedSpace': 999, @@ -62,7 +61,7 @@ class SolidFireVolumeTestCase(test.TestCase): 'thinProvisioningPercent': 100}}} return data - if method is 'GetClusterInfo': + elif method is 'GetClusterInfo' and version == '1.0': LOG.info('Called Fake GetClusterInfo...') results = {'result': {'clusterInfo': {'name': 'fake-cluster', @@ -73,11 +72,11 @@ class SolidFireVolumeTestCase(test.TestCase): 'attributes': {}}}} return results - elif method is 'AddAccount': + elif method is 'AddAccount' and version == '1.0': LOG.info('Called Fake AddAccount...') return {'result': {'accountID': 25}, 'id': 1} - elif method is 'GetAccountByName': + elif method is 'GetAccountByName' and version == '1.0': LOG.info('Called Fake GetAccountByName...') results = {'result': {'account': {'accountID': 25, @@ -90,15 +89,15 @@ class SolidFireVolumeTestCase(test.TestCase): "id": 1} return results - elif method is 'CreateVolume': + elif method is 'CreateVolume' and version == '1.0': LOG.info('Called Fake CreateVolume...') return {'result': {'volumeID': 5}, 'id': 1} - elif method is 'DeleteVolume': + elif method is 'DeleteVolume' and version == '1.0': LOG.info('Called Fake DeleteVolume...') return {'result': {}, 'id': 1} - elif method is 'ListVolumesForAccount': + elif method is 'ListVolumesForAccount' and version == '1.0': test_name = 'OS-VOLID-a720b3c0-d1f0-11e1-9b23-0800200c9a66' LOG.info('Called Fake ListVolumesForAccount...') result = {'result': { @@ -118,7 +117,7 @@ class SolidFireVolumeTestCase(test.TestCase): else: LOG.error('Crap, unimplemented API call in Fake:%s' % method) - def fake_issue_api_request_fails(obj, method, params): + def fake_issue_api_request_fails(obj, method, params, version='1.0'): return {'error': {'code': 000, 'name': 'DummyError', 'message': 'This is a fake error response'}, diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index ce4d56af6..cedf1ab5b 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -92,7 +92,7 @@ class SolidFire(SanISCSIDriver): ex.strerror) pass - def _issue_api_request(self, method_name, params): + def _issue_api_request(self, method_name, params, version='1.0'): """All API requests to SolidFire device go through this method. Simple json-rpc web based API calls. @@ -137,8 +137,9 @@ class SolidFire(SanISCSIDriver): LOG.debug(_("Payload for SolidFire API call: %s"), payload) + api_endpoint = '/json-rpc/%s' % version connection = httplib.HTTPSConnection(host, port) - connection.request('POST', '/json-rpc/1.0', payload, header) + connection.request('POST', api_endpoint, payload, header) response = connection.getresponse() data = {}