]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add missing RPC calls versions to rpcapi modules
authorMichał Dulko <michal.dulko@intel.com>
Wed, 13 Jan 2016 15:18:45 +0000 (16:18 +0100)
committerMichał Dulko <michal.dulko@intel.com>
Fri, 29 Jan 2016 13:33:29 +0000 (08:33 -0500)
Some RPC calls in rpcapi modules are not passing version indicators to
the RPC client. The RPC call version should be indicated explicitely
because otherwise it gets defaulted to the latest one or '1.0'. This
creates a set of problem in maintaining RPC API backward compatibility.

This commit changes these calls to point to the right versions according
to git history and version comments in rpcapi files.

Change-Id: Ib05d9748e18589df5a67f7b7ea668394cc8df769
Related-Blueprint: rpc-object-compatibility

cinder/backup/rpcapi.py
cinder/scheduler/rpcapi.py
cinder/tests/unit/backup/test_rpcapi.py
cinder/tests/unit/scheduler/test_rpcapi.py
cinder/tests/unit/test_volume_rpcapi.py
cinder/volume/rpcapi.py

index 19419c6298d676665535ffaeeed635fc2151df8d..d70e3bb3b25bbe5611099d60b4ed386b0086e22d 100644 (file)
@@ -53,18 +53,18 @@ class BackupAPI(object):
 
     def create_backup(self, ctxt, backup):
         LOG.debug("create_backup in rpcapi backup_id %s", backup.id)
-        cctxt = self.client.prepare(server=backup.host)
+        cctxt = self.client.prepare(server=backup.host, version='1.1')
         cctxt.cast(ctxt, 'create_backup', backup=backup)
 
     def restore_backup(self, ctxt, volume_host, backup, volume_id):
         LOG.debug("restore_backup in rpcapi backup_id %s", backup.id)
-        cctxt = self.client.prepare(server=volume_host)
+        cctxt = self.client.prepare(server=volume_host, version='1.1')
         cctxt.cast(ctxt, 'restore_backup', backup=backup,
                    volume_id=volume_id)
 
     def delete_backup(self, ctxt, backup):
         LOG.debug("delete_backup  rpcapi backup_id %s", backup.id)
-        cctxt = self.client.prepare(server=backup.host)
+        cctxt = self.client.prepare(server=backup.host, version='1.1')
         cctxt.cast(ctxt, 'delete_backup', backup=backup)
 
     def export_record(self, ctxt, backup):
@@ -72,7 +72,7 @@ class BackupAPI(object):
                   "on host %(host)s.",
                   {'id': backup.id,
                    'host': backup.host})
-        cctxt = self.client.prepare(server=backup.host)
+        cctxt = self.client.prepare(server=backup.host, version='1.1')
         return cctxt.call(ctxt, 'export_record', backup=backup)
 
     def import_record(self,
@@ -87,7 +87,7 @@ class BackupAPI(object):
                   {'id': backup.id,
                    'host': host,
                    'url': backup_url})
-        cctxt = self.client.prepare(server=host)
+        cctxt = self.client.prepare(server=host, version='1.1')
         cctxt.cast(ctxt, 'import_record',
                    backup=backup,
                    backup_service=backup_service,
@@ -99,11 +99,11 @@ class BackupAPI(object):
                   "on host %(host)s.",
                   {'id': backup.id,
                    'host': backup.host})
-        cctxt = self.client.prepare(server=backup.host)
+        cctxt = self.client.prepare(server=backup.host, version='1.1')
         return cctxt.cast(ctxt, 'reset_status', backup=backup, status=status)
 
     def check_support_to_force_delete(self, ctxt, host):
         LOG.debug("Check if backup driver supports force delete "
                   "on host %(host)s.", {'host': host})
-        cctxt = self.client.prepare(server=host)
+        cctxt = self.client.prepare(server=host, version='1.1')
         return cctxt.call(ctxt, 'check_support_to_force_delete')
index e451336e7a174d46084f8ecc7419da75526bf63c..f227be62b14a6cd8cfd19abf210b700d83f75152 100644 (file)
@@ -147,7 +147,7 @@ class SchedulerAPI(object):
                                     service_name, host,
                                     capabilities):
         # FIXME(flaper87): What to do with fanout?
-        cctxt = self.client.prepare(fanout=True)
+        cctxt = self.client.prepare(fanout=True, version='1.0')
         cctxt.cast(ctxt, 'update_service_capabilities',
                    service_name=service_name, host=host,
                    capabilities=capabilities)
index 049b710a9608e7b3fca40e531d25f0a8589821e3..4f6f745e8ffc65365a35a96fca7f13de961d7186 100644 (file)
@@ -87,7 +87,8 @@ class BackupRpcAPITestCase(test.TestCase):
         self._test_backup_api('create_backup',
                               rpc_method='cast',
                               server=self.fake_backup_obj.host,
-                              backup=self.fake_backup_obj)
+                              backup=self.fake_backup_obj,
+                              version='1.1')
 
     def test_restore_backup(self):
         self._test_backup_api('restore_backup',
@@ -95,19 +96,22 @@ class BackupRpcAPITestCase(test.TestCase):
                               server='fake_volume_host',
                               volume_host='fake_volume_host',
                               backup=self.fake_backup_obj,
-                              volume_id='fake_volume_id')
+                              volume_id='fake_volume_id',
+                              version='1.1')
 
     def test_delete_backup(self):
         self._test_backup_api('delete_backup',
                               rpc_method='cast',
                               server=self.fake_backup_obj.host,
-                              backup=self.fake_backup_obj)
+                              backup=self.fake_backup_obj,
+                              version='1.1')
 
     def test_export_record(self):
         self._test_backup_api('export_record',
                               rpc_method='call',
                               server=self.fake_backup_obj.host,
-                              backup=self.fake_backup_obj)
+                              backup=self.fake_backup_obj,
+                              version='1.1')
 
     def test_import_record(self):
         self._test_backup_api('import_record',
@@ -117,11 +121,13 @@ class BackupRpcAPITestCase(test.TestCase):
                               backup=self.fake_backup_obj,
                               backup_service='fake_service',
                               backup_url='fake_url',
-                              backup_hosts=['fake_host1', 'fake_host2'])
+                              backup_hosts=['fake_host1', 'fake_host2'],
+                              version='1.1')
 
     def test_reset_status(self):
         self._test_backup_api('reset_status',
                               rpc_method='cast',
                               server=self.fake_backup_obj.host,
                               backup=self.fake_backup_obj,
-                              status='error')
+                              status='error',
+                              version='1.1')
index 74de0baec62245fe9f110455cc5c4e3b8c6ea888..dd2f875a5aa5ac109e56e6392ce0f13bd9c0ff0f 100644 (file)
@@ -85,7 +85,8 @@ class SchedulerRpcAPITestCase(test.TestCase):
                                  service_name='fake_name',
                                  host='fake_host',
                                  capabilities='fake_capabilities',
-                                 fanout=True)
+                                 fanout=True,
+                                 version='1.0')
 
     @mock.patch('oslo_messaging.RPCClient.can_send_version',
                 return_value=True)
index c192ee791055f183184e2d2106f7840e9edcb1d4..05ec502f2f50661e213fd4904e4d0bacdbb54b26 100644 (file)
@@ -295,21 +295,24 @@ class VolumeRpcAPITestCase(test.TestCase):
         self._test_volume_api('create_snapshot',
                               rpc_method='cast',
                               volume=self.fake_volume,
-                              snapshot=self.fake_snapshot)
+                              snapshot=self.fake_snapshot,
+                              version='1.20')
 
     def test_delete_snapshot(self):
         self._test_volume_api('delete_snapshot',
                               rpc_method='cast',
                               snapshot=self.fake_snapshot,
                               host='fake_host',
-                              unmanage_only=False)
+                              unmanage_only=False,
+                              version='1.20')
 
     def test_delete_snapshot_with_unmanage_only(self):
         self._test_volume_api('delete_snapshot',
                               rpc_method='cast',
                               snapshot=self.fake_snapshot,
                               host='fake_host',
-                              unmanage_only=True)
+                              unmanage_only=True,
+                              version='1.20')
 
     def test_attach_volume_to_instance(self):
         self._test_volume_api('attach_volume',
@@ -351,14 +354,16 @@ class VolumeRpcAPITestCase(test.TestCase):
         self._test_volume_api('initialize_connection',
                               rpc_method='call',
                               volume=self.fake_volume,
-                              connector='fake_connector')
+                              connector='fake_connector',
+                              version='1.0')
 
     def test_terminate_connection(self):
         self._test_volume_api('terminate_connection',
                               rpc_method='call',
                               volume=self.fake_volume,
                               connector='fake_connector',
-                              force=False)
+                              force=False,
+                              version='1.0')
 
     def test_accept_transfer(self):
         self._test_volume_api('accept_transfer',
index 89879c56ff9af7be84d5cfdc5b42032443e6723f..9600a140bd4d7b4827f24423372e16eec824768e 100644 (file)
@@ -173,13 +173,13 @@ class VolumeAPI(object):
 
     def create_snapshot(self, ctxt, volume, snapshot):
         new_host = utils.extract_host(volume['host'])
-        cctxt = self.client.prepare(server=new_host)
+        cctxt = self.client.prepare(server=new_host, version='1.20')
         cctxt.cast(ctxt, 'create_snapshot', volume_id=volume['id'],
                    snapshot=snapshot)
 
     def delete_snapshot(self, ctxt, snapshot, host, unmanage_only=False):
         new_host = utils.extract_host(host)
-        cctxt = self.client.prepare(server=new_host)
+        cctxt = self.client.prepare(server=new_host, version='1.20')
         cctxt.cast(ctxt, 'delete_snapshot', snapshot=snapshot,
                    unmanage_only=unmanage_only)
 
@@ -209,14 +209,14 @@ class VolumeAPI(object):
 
     def initialize_connection(self, ctxt, volume, connector):
         new_host = utils.extract_host(volume['host'])
-        cctxt = self.client.prepare(server=new_host)
+        cctxt = self.client.prepare(server=new_host, version='1.0')
         return cctxt.call(ctxt, 'initialize_connection',
                           volume_id=volume['id'],
                           connector=connector)
 
     def terminate_connection(self, ctxt, volume, connector, force=False):
         new_host = utils.extract_host(volume['host'])
-        cctxt = self.client.prepare(server=new_host)
+        cctxt = self.client.prepare(server=new_host, version='1.0')
         return cctxt.call(ctxt, 'terminate_connection', volume_id=volume['id'],
                           connector=connector, force=force)