From 599fff650ff45c06c46ef62cd6409dc3eff27227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Thu, 17 Mar 2016 13:20:48 +0100 Subject: [PATCH] Remove support for 1.x Backup RPC API Change-Id: I1d1e0b0ee22d186a6557e9fee805b18ad6b78ad6 --- cinder/backup/manager.py | 34 ----------- cinder/backup/rpcapi.py | 16 ++--- cinder/tests/unit/backup/test_rpcapi.py | 79 +++---------------------- 3 files changed, 16 insertions(+), 113 deletions(-) diff --git a/cinder/backup/manager.py b/cinder/backup/manager.py index 2b1ecdf1411..a72c1a9cdb4 100644 --- a/cinder/backup/manager.py +++ b/cinder/backup/manager.py @@ -95,7 +95,6 @@ class BackupManager(manager.SchedulerDependentManager): self.volume_rpcapi = volume_rpcapi.VolumeAPI() super(BackupManager, self).__init__(service_name='backup', *args, **kwargs) - self.additional_endpoints.append(_BackupV1Proxy(self)) @property def driver_name(self): @@ -858,36 +857,3 @@ class BackupManager(manager.SchedulerDependentManager): rpcapi = self.volume_rpcapi rpcapi.terminate_connection(context, volume, properties, force=force) rpcapi.remove_export(context, volume) - - -# TODO(dulek): This goes away immediately in Newton and is just present in -# Mitaka so that we can receive v1.x and v2.0 messages. -class _BackupV1Proxy(object): - - target = messaging.Target(version='1.3') - - def __init__(self, manager): - self.manager = manager - - def create_backup(self, context, backup): - return self.manager.create_backup(context, backup) - - def restore_backup(self, context, backup, volume_id): - return self.manager.restore_backup(context, backup, volume_id) - - def delete_backup(self, context, backup): - return self.manager.delete_backup(context, backup) - - def export_record(self, context, backup): - return self.manager.export_record(context, backup) - - def import_record(self, context, backup, backup_service, backup_url, - backup_hosts): - return self.manager.import_record(context, backup, backup_service, - backup_url, backup_hosts) - - def reset_status(self, context, backup, status): - return self.manager.reset_status(context, backup, status) - - def check_support_to_force_delete(self, context): - return self.manager.check_support_to_force_delete(context) diff --git a/cinder/backup/rpcapi.py b/cinder/backup/rpcapi.py index a46ef3f2aa6..d170655862a 100644 --- a/cinder/backup/rpcapi.py +++ b/cinder/backup/rpcapi.py @@ -48,7 +48,7 @@ class BackupAPI(rpc.RPCAPI): 2.0 - Remove 1.x compatibility """ - RPC_API_VERSION = '1.3' + RPC_API_VERSION = '2.0' TOPIC = CONF.backup_topic BINARY = 'cinder-backup' @@ -60,20 +60,20 @@ class BackupAPI(rpc.RPCAPI): def create_backup(self, ctxt, backup): LOG.debug("create_backup in rpcapi backup_id %s", backup.id) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=backup.host, version=version) 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) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=volume_host, version=version) 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) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=backup.host, version=version) cctxt.cast(ctxt, 'delete_backup', backup=backup) @@ -82,7 +82,7 @@ class BackupAPI(rpc.RPCAPI): "on host %(host)s.", {'id': backup.id, 'host': backup.host}) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=backup.host, version=version) return cctxt.call(ctxt, 'export_record', backup=backup) @@ -98,7 +98,7 @@ class BackupAPI(rpc.RPCAPI): {'id': backup.id, 'host': host, 'url': backup_url}) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=host, version=version) cctxt.cast(ctxt, 'import_record', backup=backup, @@ -111,13 +111,13 @@ class BackupAPI(rpc.RPCAPI): "on host %(host)s.", {'id': backup.id, 'host': backup.host}) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=backup.host, version=version) 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}) - version = self._compat_ver('2.0', '1.1') + version = '2.0' cctxt = self.client.prepare(server=host, version=version) return cctxt.call(ctxt, 'check_support_to_force_delete') diff --git a/cinder/tests/unit/backup/test_rpcapi.py b/cinder/tests/unit/backup/test_rpcapi.py index 72a2d12dbb9..f1e13ad80b1 100644 --- a/cinder/tests/unit/backup/test_rpcapi.py +++ b/cinder/tests/unit/backup/test_rpcapi.py @@ -80,72 +80,37 @@ class BackupRpcAPITestCase(test.TestCase): else: self.assertEqual(expected_msg[kwarg], value) - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_create_backup(self, can_send_version): + def test_create_backup(self): self._test_backup_api('create_backup', rpc_method='cast', server=self.fake_backup_obj.host, backup=self.fake_backup_obj, version='2.0') - can_send_version.return_value = False - self._test_backup_api('create_backup', - rpc_method='cast', - server=self.fake_backup_obj.host, - backup=self.fake_backup_obj, - version='1.1') - - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_restore_backup(self, can_send_version): - self._test_backup_api('restore_backup', - rpc_method='cast', - server='fake_volume_host', - volume_host='fake_volume_host', - backup=self.fake_backup_obj, - volume_id='fake_volume_id', - version='2.0') - - can_send_version.return_value = False + def test_restore_backup(self): self._test_backup_api('restore_backup', rpc_method='cast', server='fake_volume_host', volume_host='fake_volume_host', backup=self.fake_backup_obj, volume_id=fake.VOLUME_ID, - version='1.1') + version='2.0') - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_delete_backup(self, can_send_version): + 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, version='2.0') - can_send_version.return_value = False - self._test_backup_api('delete_backup', - rpc_method='cast', - server=self.fake_backup_obj.host, - backup=self.fake_backup_obj, - version='1.1') - - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_export_record(self, can_send_version): + 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, version='2.0') - can_send_version.return_value = False - self._test_backup_api('export_record', - rpc_method='call', - server=self.fake_backup_obj.host, - backup=self.fake_backup_obj, - version='1.1') - - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_import_record(self, can_send_version): + def test_import_record(self): self._test_backup_api('import_record', rpc_method='cast', server='fake_volume_host', @@ -156,19 +121,7 @@ class BackupRpcAPITestCase(test.TestCase): backup_hosts=['fake_host1', 'fake_host2'], version='2.0') - can_send_version.return_value = False - self._test_backup_api('import_record', - rpc_method='cast', - server='fake_volume_host', - host='fake_volume_host', - backup=self.fake_backup_obj, - backup_service='fake_service', - backup_url='fake_url', - backup_hosts=['fake_host1', 'fake_host2'], - version='1.1') - - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_reset_status(self, can_send_version): + def test_reset_status(self): self._test_backup_api('reset_status', rpc_method='cast', server=self.fake_backup_obj.host, @@ -176,25 +129,9 @@ class BackupRpcAPITestCase(test.TestCase): status='error', version='2.0') - can_send_version.return_value = False - self._test_backup_api('reset_status', - rpc_method='cast', - server=self.fake_backup_obj.host, - backup=self.fake_backup_obj, - status='error', - version='1.1') - - @mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True) - def test_check_support_to_force_delete(self, can_send_version): + def test_check_support_to_force_delete(self): self._test_backup_api('check_support_to_force_delete', rpc_method='call', server='fake_volume_host', host='fake_volume_host', version='2.0') - - can_send_version.return_value = False - self._test_backup_api('check_support_to_force_delete', - rpc_method='call', - server='fake_volume_host', - host='fake_volume_host', - version='1.1')