From 45145e596960f963a65d8706d0664facc2677a86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Dulko?= Date: Wed, 13 Jan 2016 16:18:45 +0100 Subject: [PATCH] Add missing RPC calls versions to rpcapi modules 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 | 14 +++++++------- cinder/scheduler/rpcapi.py | 2 +- cinder/tests/unit/backup/test_rpcapi.py | 18 ++++++++++++------ cinder/tests/unit/scheduler/test_rpcapi.py | 3 ++- cinder/tests/unit/test_volume_rpcapi.py | 15 ++++++++++----- cinder/volume/rpcapi.py | 8 ++++---- 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/cinder/backup/rpcapi.py b/cinder/backup/rpcapi.py index 19419c629..d70e3bb3b 100644 --- a/cinder/backup/rpcapi.py +++ b/cinder/backup/rpcapi.py @@ -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') diff --git a/cinder/scheduler/rpcapi.py b/cinder/scheduler/rpcapi.py index e451336e7..f227be62b 100644 --- a/cinder/scheduler/rpcapi.py +++ b/cinder/scheduler/rpcapi.py @@ -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) diff --git a/cinder/tests/unit/backup/test_rpcapi.py b/cinder/tests/unit/backup/test_rpcapi.py index 049b710a9..4f6f745e8 100644 --- a/cinder/tests/unit/backup/test_rpcapi.py +++ b/cinder/tests/unit/backup/test_rpcapi.py @@ -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') diff --git a/cinder/tests/unit/scheduler/test_rpcapi.py b/cinder/tests/unit/scheduler/test_rpcapi.py index 74de0baec..dd2f875a5 100644 --- a/cinder/tests/unit/scheduler/test_rpcapi.py +++ b/cinder/tests/unit/scheduler/test_rpcapi.py @@ -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) diff --git a/cinder/tests/unit/test_volume_rpcapi.py b/cinder/tests/unit/test_volume_rpcapi.py index c192ee791..05ec502f2 100644 --- a/cinder/tests/unit/test_volume_rpcapi.py +++ b/cinder/tests/unit/test_volume_rpcapi.py @@ -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', diff --git a/cinder/volume/rpcapi.py b/cinder/volume/rpcapi.py index 89879c56f..9600a140b 100644 --- a/cinder/volume/rpcapi.py +++ b/cinder/volume/rpcapi.py @@ -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) -- 2.45.2