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): def driver_name(self):
"""This function maps old backup services to backup drivers.""" """This function maps old backup services to backup drivers."""
return self._map_service_to_driver(CONF.backup_driver) return 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
def get_backup_driver(self, context): def get_backup_driver(self, context):
driver = None driver = None
@ -522,7 +510,7 @@ class BackupManager(manager.ThreadPoolManager):
'backup_id': backup['id'], 'backup_id': backup['id'],
'backup_size': backup['size']}) 'backup_size': backup['size']})
backup_service = self._map_service_to_driver(backup['service']) backup_service = backup['service']
configured_service = self.driver_name configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module # TODO(tommylikehu): We upgraded the 'driver_name' from module
# to class name, so we use 'in' here to match two namings, # 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) self._update_backup_error(backup, err, status)
raise exception.InvalidBackup(reason=err) raise exception.InvalidBackup(reason=err)
backup_service = self._map_service_to_driver(backup['service']) backup_service = backup['service']
if backup_service is not None: if backup_service is not None:
configured_service = self.driver_name configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module # TODO(tommylikehu): We upgraded the 'driver_name' from module
@ -754,7 +742,7 @@ class BackupManager(manager.ThreadPoolManager):
raise exception.InvalidBackup(reason=err) raise exception.InvalidBackup(reason=err)
backup_record = {'backup_service': backup.service} backup_record = {'backup_service': backup.service}
backup_service = self._map_service_to_driver(backup.service) backup_service = backup.service
configured_service = self.driver_name configured_service = self.driver_name
# TODO(tommylikehu): We upgraded the 'driver_name' from module # TODO(tommylikehu): We upgraded the 'driver_name' from module
# to class name, so we use 'in' here to match two namings, # to class name, so we use 'in' here to match two namings,
@ -913,7 +901,7 @@ class BackupManager(manager.ThreadPoolManager):
{'backup_id': backup.id, {'backup_id': backup.id,
'status': status}) '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) LOG.info('Backup service: %s.', backup_service_name)
if backup_service_name is not None: if backup_service_name is not None:
configured_service = self.driver_name 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') backups = db.backup_get_all_by_host(ctxt_read_deleted, 'testhost')
self.assertEqual(2, len(backups)) 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): def test_export_record_with_bad_service(self):
"""Test error handling. """Test error handling.
@ -1725,34 +1717,31 @@ class BackupTestCaseWithVerify(BaseBackupTest):
'_cleanup_temp_volumes_snapshots_for_one_backup') '_cleanup_temp_volumes_snapshots_for_one_backup')
def test_backup_reset_status_from_nonrestoring_to_available( def test_backup_reset_status_from_nonrestoring_to_available(
self, mock_clean_temp): 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', vol_id = self._create_volume_db_entry(status='available',
size=1) size=1)
backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR, backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR,
volume_id=vol_id) volume_id=vol_id,
with mock.patch.object(manager.BackupManager, service=service_name)
'_map_service_to_driver') as \ self.backup_mgr.reset_status(self.ctxt,
mock_map_service_to_driver: backup,
# It should works when the service name is a string fields.BackupStatus.AVAILABLE)
backup_driver = 'cinder.tests.unit.backup.fake_service_with_verify' mock_clean_temp.assert_called_once_with(self.ctxt, backup)
mock_map_service_to_driver.return_value = backup_driver new_backup = db.backup_get(self.ctxt, backup.id)
self.backup_mgr.reset_status(self.ctxt, self.assertEqual(fields.BackupStatus.AVAILABLE,
backup, new_backup['status'])
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,
self.backup_mgr.reset_status(self.ctxt, backup,
backup, fields.BackupStatus.ERROR)
fields.BackupStatus.ERROR) mock_clean_temp.reset_mock()
mock_clean_temp.reset_mock()
self.backup_mgr.reset_status(self.ctxt, self.backup_mgr.reset_status(self.ctxt,
backup, backup,
fields.BackupStatus.AVAILABLE) fields.BackupStatus.AVAILABLE)
mock_clean_temp.assert_called_once_with(self.ctxt, backup) mock_clean_temp.assert_called_once_with(self.ctxt, backup)
backup = db.backup_get(self.ctxt, backup.id) backup = db.backup_get(self.ctxt, backup.id)
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status']) 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.