db: Remove 'db_driver' option
This is a silly config option. We only have one database driver in-tree and no plans to add more (SQLAlchemy is best in class). There's also no way we'd be able to support out-of-tree drivers. Remove it entirely. Change-Id: Ica3b2e8fcb079beca652e81d2230bcca82fb49d7 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
ee771bbdbc
commit
8353d6e204
@ -59,11 +59,12 @@ IMPORT_VOLUME_ID = '00000000-0000-0000-0000-000000000000'
|
||||
class API(base.Base):
|
||||
"""API for interacting with the volume backup manager."""
|
||||
|
||||
# TODO(stephenfin): The 'db' kwarg is unused; remove it
|
||||
def __init__(self, db=None):
|
||||
self.backup_rpcapi = backup_rpcapi.BackupAPI()
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
self.volume_api = cinder.volume.API()
|
||||
super(API, self).__init__(db)
|
||||
super(API, self).__init__()
|
||||
|
||||
def get(self, context, backup_id):
|
||||
backup = objects.Backup.get_by_id(context, backup_id)
|
||||
|
@ -52,8 +52,9 @@ class BackupMetadataAPI(base.Base):
|
||||
TYPE_TAG_VOL_META = 'volume-metadata'
|
||||
TYPE_TAG_VOL_GLANCE_META = 'volume-glance-metadata'
|
||||
|
||||
def __init__(self, context, db=None):
|
||||
super(BackupMetadataAPI, self).__init__(db)
|
||||
# TODO(stephenfin): The 'db' kwarg is unused; remove it
|
||||
def __init__(self, context):
|
||||
super().__init__()
|
||||
self.context = context
|
||||
self._key_mgr = None
|
||||
|
||||
@ -347,10 +348,11 @@ class BackupMetadataAPI(base.Base):
|
||||
|
||||
class BackupDriver(base.Base, metaclass=abc.ABCMeta):
|
||||
|
||||
# TODO(stephenfin): The 'db' kwarg is unused; remove it
|
||||
def __init__(self, context, db=None):
|
||||
super(BackupDriver, self).__init__(db)
|
||||
super().__init__()
|
||||
self.context = context
|
||||
self.backup_meta_api = BackupMetadataAPI(context, db)
|
||||
self.backup_meta_api = BackupMetadataAPI(context)
|
||||
# This flag indicates if backup driver supports force
|
||||
# deletion. So it should be set to True if the driver that inherits
|
||||
# from BackupDriver supports the force deletion function.
|
||||
|
@ -16,32 +16,14 @@
|
||||
|
||||
"""Base class for classes that need modular database access."""
|
||||
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
|
||||
|
||||
db_driver_opt = cfg.StrOpt('db_driver',
|
||||
default='cinder.db',
|
||||
help='Driver to use for database access')
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opt(db_driver_opt)
|
||||
import cinder.db
|
||||
|
||||
|
||||
class Base(object):
|
||||
"""DB driver is injected in the init method."""
|
||||
|
||||
def __init__(self, db_driver=None):
|
||||
# NOTE(mriedem): Without this call, multiple inheritance involving
|
||||
# the db Base class does not work correctly.
|
||||
super(Base, self).__init__()
|
||||
if not db_driver:
|
||||
db_driver = CONF.db_driver
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# pylint: disable=C0103
|
||||
if isinstance(db_driver, str):
|
||||
self.db = importutils.import_module(db_driver)
|
||||
else:
|
||||
self.db = db_driver
|
||||
self.db = cinder.db
|
||||
self.db.dispose_engine()
|
||||
|
@ -60,12 +60,12 @@ VALID_ADD_VOL_TO_GROUP_STATUS = (
|
||||
class API(base.Base):
|
||||
"""API for interacting with the volume manager for groups."""
|
||||
|
||||
def __init__(self, db_driver=None):
|
||||
def __init__(self):
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
self.volume_rpcapi = volume_rpcapi.VolumeAPI()
|
||||
self.volume_api = volume_api.API()
|
||||
|
||||
super(API, self).__init__(db_driver)
|
||||
super().__init__()
|
||||
|
||||
def _extract_availability_zone(self, availability_zone):
|
||||
raw_zones = self.volume_api.list_availability_zones(enable_cache=True)
|
||||
|
@ -84,18 +84,19 @@ class Manager(base.Base, PeriodicTasks):
|
||||
|
||||
target = messaging.Target(version=RPC_API_VERSION)
|
||||
|
||||
def __init__(self,
|
||||
host: oslo_config.types.HostAddress = None,
|
||||
db_driver=None,
|
||||
cluster=None,
|
||||
**_kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
host: oslo_config.types.HostAddress = None,
|
||||
cluster=None,
|
||||
**_kwargs,
|
||||
):
|
||||
if not host:
|
||||
host = CONF.host
|
||||
self.host: oslo_config.types.HostAddress = host
|
||||
self.cluster = cluster
|
||||
self.additional_endpoints: list = []
|
||||
self.availability_zone = CONF.storage_availability_zone
|
||||
super(Manager, self).__init__(db_driver) # type: ignore
|
||||
super().__init__() # type: ignore
|
||||
|
||||
def _set_tpool_size(self, nthreads: int) -> None:
|
||||
# NOTE(geguileo): Until PR #472 is merged we have to be very careful
|
||||
@ -178,14 +179,18 @@ class SchedulerDependentManager(ThreadPoolManager):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, host=None, db_driver=None, service_name='undefined',
|
||||
cluster=None, *args, **kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
host=None,
|
||||
service_name='undefined',
|
||||
cluster=None,
|
||||
*args,
|
||||
**kwargs,
|
||||
):
|
||||
self.last_capabilities = None
|
||||
self.service_name = service_name
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
super(SchedulerDependentManager, self).__init__(host, db_driver,
|
||||
cluster=cluster,
|
||||
*args, **kwargs)
|
||||
super().__init__(host, cluster=cluster, *args, **kwargs)
|
||||
|
||||
def update_service_capabilities(self, capabilities):
|
||||
"""Remember these capabilities to send on next periodic update."""
|
||||
|
@ -49,7 +49,6 @@ from cinder.compute import nova as cinder_compute_nova
|
||||
from cinder import context as cinder_context
|
||||
from cinder import coordination as cinder_coordination
|
||||
from cinder.db import api as cinder_db_api
|
||||
from cinder.db import base as cinder_db_base
|
||||
from cinder.image import glance as cinder_image_glance
|
||||
from cinder.image import image_utils as cinder_image_imageutils
|
||||
from cinder.keymgr import conf_key_mgr as cinder_keymgr_confkeymgr
|
||||
@ -242,7 +241,6 @@ def list_opts():
|
||||
cinder_context.context_opts,
|
||||
cinder_db_api.db_opts,
|
||||
cinder_db_api.backup_opts,
|
||||
[cinder_db_base.db_driver_opt],
|
||||
cinder_image_glance.image_opts,
|
||||
cinder_image_glance.glance_core_properties_opts,
|
||||
cinder_image_imageutils.image_opts,
|
||||
|
@ -1090,7 +1090,7 @@ class TestFetchToRaw(test.TestCase):
|
||||
|
||||
|
||||
class FakeImageService(object):
|
||||
def __init__(self, db_driver=None, image_service=None, disk_format='raw'):
|
||||
def __init__(self, image_service=None, disk_format='raw'):
|
||||
self.temp_images = None
|
||||
self.disk_format = disk_format
|
||||
|
||||
@ -1818,8 +1818,7 @@ class TestFetchToVolumeFormat(test.TestCase):
|
||||
pass
|
||||
|
||||
class FakeImageService(object):
|
||||
def __init__(self, db_driver=None,
|
||||
image_service=None, disk_format='raw'):
|
||||
def __init__(self, image_service=None, disk_format='raw'):
|
||||
self.temp_images = None
|
||||
self.disk_format = disk_format
|
||||
|
||||
|
@ -52,11 +52,8 @@ CONF.register_opts(test_service_opts)
|
||||
|
||||
class FakeManager(manager.Manager):
|
||||
"""Fake manager for tests."""
|
||||
def __init__(self, host=None,
|
||||
db_driver=None, service_name=None, cluster=None):
|
||||
super(FakeManager, self).__init__(host=host,
|
||||
db_driver=db_driver,
|
||||
cluster=cluster)
|
||||
def __init__(self, host=None, service_name=None, cluster=None):
|
||||
super().__init__(host=host, cluster=cluster)
|
||||
|
||||
def test_method(self):
|
||||
return 'manager'
|
||||
|
@ -26,12 +26,12 @@ import ddt
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_service import loopingcall
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import units
|
||||
import paramiko
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
import cinder.db
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import objects
|
||||
@ -3119,8 +3119,7 @@ class StorwizeSVCISCSIDriverTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.iscsi_driver.db = self.db
|
||||
self.iscsi_driver.do_setup(None)
|
||||
self.iscsi_driver.check_for_setup_error()
|
||||
@ -3758,8 +3757,7 @@ class StorwizeSVCFcDriverTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = self.fc_driver.configuration.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.fc_driver.db = self.db
|
||||
self.fc_driver.do_setup(None)
|
||||
self.fc_driver.check_for_setup_error()
|
||||
@ -4593,8 +4591,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
||||
else:
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.driver.db = self.db
|
||||
self.driver.do_setup(None)
|
||||
self.driver.check_for_setup_error()
|
||||
@ -9873,10 +9870,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = self.driver.configuration.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.driver.db = self.db
|
||||
|
||||
self.driver.do_setup(None)
|
||||
self.driver.check_for_setup_error()
|
||||
self._create_test_volume_types()
|
||||
|
@ -21,11 +21,11 @@ import ddt
|
||||
from eventlet import greenthread
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import units
|
||||
import paramiko
|
||||
|
||||
from cinder import context
|
||||
from cinder import db
|
||||
from cinder import exception
|
||||
from cinder import objects
|
||||
from cinder.objects import fields
|
||||
@ -77,9 +77,7 @@ class InStorageMCSCommonDriverTestCase(test.TestCase):
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.driver.db = self.db
|
||||
self.driver.db = db
|
||||
self.driver.do_setup(None)
|
||||
self.driver.check_for_setup_error()
|
||||
self.driver._assistant.check_lcmapping_interval = 0
|
||||
@ -319,7 +317,7 @@ class InStorageMCSCommonDriverTestCase(test.TestCase):
|
||||
|
||||
def _delete_volume(self, volume):
|
||||
self.driver.delete_volume(volume)
|
||||
self.db.volume_destroy(self.ctxt, volume['id'])
|
||||
db.volume_destroy(self.ctxt, volume['id'])
|
||||
|
||||
def _create_group_in_db(self, **kwargs):
|
||||
group = testutils.create_group(self.ctxt, **kwargs)
|
||||
@ -340,8 +338,7 @@ class InStorageMCSCommonDriverTestCase(test.TestCase):
|
||||
**kwargs)
|
||||
snapshots = []
|
||||
grp_id = group_snapshot['group_id']
|
||||
volumes = self.db.volume_get_all_by_group(self.ctxt.elevated(),
|
||||
grp_id)
|
||||
volumes = db.volume_get_all_by_group(self.ctxt.elevated(), grp_id)
|
||||
|
||||
if not volumes:
|
||||
msg = "Group is empty. No group snapshot will be created."
|
||||
|
@ -18,9 +18,9 @@
|
||||
from unittest import mock
|
||||
|
||||
from eventlet import greenthread
|
||||
from oslo_utils import importutils
|
||||
|
||||
from cinder import context
|
||||
import cinder.db
|
||||
from cinder import exception
|
||||
from cinder.tests.unit import test
|
||||
from cinder.tests.unit import utils as testutils
|
||||
@ -58,8 +58,7 @@ class InStorageMCSFcDriverTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = self.fc_driver.configuration.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.fc_driver.db = self.db
|
||||
self.fc_driver.do_setup(None)
|
||||
self.fc_driver.check_for_setup_error()
|
||||
|
@ -18,10 +18,10 @@
|
||||
from unittest import mock
|
||||
|
||||
from eventlet import greenthread
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
from cinder import context
|
||||
import cinder.db
|
||||
from cinder import exception
|
||||
from cinder.tests.unit import test
|
||||
from cinder.tests.unit import utils as testutils
|
||||
@ -57,8 +57,7 @@ class InStorageMCSISCSIDriverTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = self.iscsi_driver.configuration.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.iscsi_driver.db = self.db
|
||||
self.iscsi_driver.do_setup(None)
|
||||
self.iscsi_driver.check_for_setup_error()
|
||||
|
@ -19,10 +19,10 @@ import json
|
||||
from unittest import mock
|
||||
|
||||
from eventlet import greenthread
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import units
|
||||
|
||||
from cinder import context
|
||||
import cinder.db
|
||||
from cinder import exception
|
||||
from cinder.objects import fields
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
@ -86,9 +86,7 @@ class InStorageMCSReplicationTestCase(test.TestCase):
|
||||
|
||||
self._reset_flags()
|
||||
self.ctxt = context.get_admin_context()
|
||||
db_driver = self.driver.configuration.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.driver.db = self.db
|
||||
self.driver.db = cinder.db
|
||||
|
||||
self.driver.do_setup(None)
|
||||
self.driver.check_for_setup_error()
|
||||
|
@ -27,11 +27,11 @@ from eventlet import greenthread
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import units
|
||||
import paramiko
|
||||
|
||||
from cinder import context
|
||||
import cinder.db
|
||||
from cinder import exception
|
||||
from cinder import ssh_utils
|
||||
from cinder.tests.unit import test
|
||||
@ -675,8 +675,7 @@ class Acs5000ISCSIDriverTestCase(test.TestCase):
|
||||
self.iscsi_driver.set_fake_storage(self.sim)
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self.iscsi_driver.db = self.db
|
||||
self.iscsi_driver.get_driver_options()
|
||||
self.iscsi_driver.do_setup(None)
|
||||
@ -835,8 +834,7 @@ class Acs5000CommonDriverTestCase(test.TestCase):
|
||||
self._driver.set_fake_storage(self.sim)
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
||||
db_driver = CONF.db_driver
|
||||
self.db = importutils.import_module(db_driver)
|
||||
self.db = cinder.db
|
||||
self._driver.db = self.db
|
||||
self._driver.do_setup(None)
|
||||
self._driver.check_for_setup_error()
|
||||
|
@ -43,7 +43,7 @@ NON_EXISTENT_IMAGE_ID = '003f540f-ec6b-4293-a3f9-7c68646b0f5c'
|
||||
|
||||
|
||||
class FakeImageService(object):
|
||||
def __init__(self, db_driver=None, image_service=None):
|
||||
def __init__(self, image_service=None):
|
||||
pass
|
||||
|
||||
def show(self, context, image_id):
|
||||
|
@ -56,9 +56,9 @@ QUOTAS = quota.QUOTAS
|
||||
class API(base.Base):
|
||||
"""API for interacting volume transfers."""
|
||||
|
||||
def __init__(self, db_driver=None):
|
||||
def __init__(self):
|
||||
self.volume_api = volume_api.API()
|
||||
super(API, self).__init__(db_driver)
|
||||
super().__init__()
|
||||
|
||||
def get(self, context, transfer_id):
|
||||
context.authorize(policy.GET_POLICY)
|
||||
|
@ -102,7 +102,7 @@ class API(base.Base):
|
||||
|
||||
AVAILABLE_MIGRATION_STATUS = (None, 'deleting', 'error', 'success')
|
||||
|
||||
def __init__(self, db_driver=None, image_service=None):
|
||||
def __init__(self, image_service=None):
|
||||
self.image_service = (image_service or
|
||||
glance.get_default_image_service())
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
@ -111,7 +111,7 @@ class API(base.Base):
|
||||
self.availability_zones_last_fetched = None
|
||||
self.key_manager = key_manager.API(CONF)
|
||||
self.message = message_api.API()
|
||||
super(API, self).__init__(db_driver)
|
||||
super().__init__()
|
||||
|
||||
def list_availability_zones(self, enable_cache=False, refresh_cache=False):
|
||||
"""Describe the known availability zones
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The ``[DEFAULT] db_driver`` config option has been removed. This was
|
||||
intended to allow configuration of the database driver, however, there
|
||||
is only one database driver present in-tree and out-of-tree database
|
||||
drivers are not supported.
|
Loading…
Reference in New Issue
Block a user