]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add ability to specify SolidFire API version
authorMathieu Gagné <mgagne@iweb.com>
Tue, 9 Jul 2013 01:11:59 +0000 (21:11 -0400)
committerMathieu Gagné <mgagne@iweb.com>
Tue, 9 Jul 2013 01:11:59 +0000 (21:11 -0400)
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

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

index 8679f4142debd394aafd18b57002dd30650cad1c..bb2bc06e6502edd550221d5531bc0201ee3a8f47 100644 (file)
@@ -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'},
index ce4d56af6ee91029b69942b99f522451bebafd0e..cedf1ab5b9f6fc4aa15f5dde0a417a5493acbbd2 100644 (file)
@@ -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 = {}