Remove deprecated service-to-driver mapping for backups

It was deprecated in Queens and now it's safe to remove this feature.

Change-Id: Idf5aafae7a7e0c0bdcb857ec1f5c939671d8ae54
This commit is contained in:
Ivan Kolodyazhny 2018-02-13 19:31:34 +02:00
parent 3008a3aff8
commit 497cd4e3cd
3 changed files with 32 additions and 48 deletions

View File

@ -109,19 +109,7 @@ class BackupManager(manager.ThreadPoolManager):
def driver_name(self):
"""This function maps old backup services to backup drivers."""
return self._map_service_to_driver(CONF.backup_driver)
def _map_service_to_driver(self, service):
"""Maps services to drivers."""
if service in mapper:
msg = ("Using legacy backup service configuration like "
"cinder.backup.services.* is deprecated and "
"will be removed in the 'R' release. Please use "
"the cinder.backup.drivers.* method instead.")
versionutils.report_deprecated_feature(LOG, msg)
return mapper[service]
return service
return CONF.backup_driver
def get_backup_driver(self, context):
driver = None
@ -522,7 +510,7 @@ class BackupManager(manager.ThreadPoolManager):
'backup_id': backup['id'],
'backup_size': backup['size']})
backup_service = self._map_service_to_driver(backup['service'])
backup_service = backup['service']
configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module
# to class name, so we use 'in' here to match two namings,
@ -658,7 +646,7 @@ class BackupManager(manager.ThreadPoolManager):
self._update_backup_error(backup, err, status)
raise exception.InvalidBackup(reason=err)
backup_service = self._map_service_to_driver(backup['service'])
backup_service = backup['service']
if backup_service is not None:
configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module
@ -754,7 +742,7 @@ class BackupManager(manager.ThreadPoolManager):
raise exception.InvalidBackup(reason=err)
backup_record = {'backup_service': backup.service}
backup_service = self._map_service_to_driver(backup.service)
backup_service = backup.service
configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module
# to class name, so we use 'in' here to match two namings,
@ -913,7 +901,7 @@ class BackupManager(manager.ThreadPoolManager):
{'backup_id': backup.id,
'status': status})
backup_service_name = self._map_service_to_driver(backup.service)
backup_service_name = backup.service
LOG.info('Backup service: %s.', backup_service_name)
if backup_service_name is not None:
configured_service = self.driver_name

View File

@ -1452,14 +1452,6 @@ class BackupTestCase(BaseBackupTest):
backups = db.backup_get_all_by_host(ctxt_read_deleted, 'testhost')
self.assertEqual(2, len(backups))
def test_backup_manager_driver_name(self):
"""Test mapping between backup services and backup drivers."""
self.override_config('backup_driver', "cinder.backup.services.swift")
backup_mgr = \
importutils.import_object(CONF.backup_manager)
self.assertEqual('cinder.backup.drivers.swift',
backup_mgr.driver_name)
def test_export_record_with_bad_service(self):
"""Test error handling.
@ -1725,34 +1717,31 @@ class BackupTestCaseWithVerify(BaseBackupTest):
'_cleanup_temp_volumes_snapshots_for_one_backup')
def test_backup_reset_status_from_nonrestoring_to_available(
self, mock_clean_temp):
service_name = ('cinder.tests.unit.backup.'
'fake_service_with_verify.FakeBackupServiceWithVerify')
self.override_config('backup_driver', service_name)
vol_id = self._create_volume_db_entry(status='available',
size=1)
backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR,
volume_id=vol_id)
with mock.patch.object(manager.BackupManager,
'_map_service_to_driver') as \
mock_map_service_to_driver:
# It should works when the service name is a string
backup_driver = 'cinder.tests.unit.backup.fake_service_with_verify'
mock_map_service_to_driver.return_value = backup_driver
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.AVAILABLE)
mock_clean_temp.assert_called_once_with(self.ctxt, backup)
new_backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fields.BackupStatus.AVAILABLE,
new_backup['status'])
volume_id=vol_id,
service=service_name)
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.AVAILABLE)
mock_clean_temp.assert_called_once_with(self.ctxt, backup)
new_backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fields.BackupStatus.AVAILABLE,
new_backup['status'])
mock_map_service_to_driver.return_value = backup_driver
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.ERROR)
mock_clean_temp.reset_mock()
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.ERROR)
mock_clean_temp.reset_mock()
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.AVAILABLE)
mock_clean_temp.assert_called_once_with(self.ctxt, backup)
self.backup_mgr.reset_status(self.ctxt,
backup,
fields.BackupStatus.AVAILABLE)
mock_clean_temp.assert_called_once_with(self.ctxt, backup)
backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
Backup service to driver mapping is removed. If you use old values like
'cinder.backup.services.swift' or 'cinder.backup.services.ceph' it should
be changed to 'cinder.backup.drivers.swift' or 'cinder.backup.drivers.ceph'
accordingly to get your backup service working.