1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2010 United States Government as represented by the
4
# Administrator of the National Aeronautics and Space Administration.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
"""Base class for classes that need modular database access."""
21
from cinder import flags
22
from cinder.openstack.common import cfg
23
from cinder.openstack.common import importutils
26
db_driver_opt = cfg.StrOpt('db_driver',
28
help='driver to use for database access')
31
FLAGS.register_opt(db_driver_opt)
35
"""DB driver is injected in the init method."""
37
def __init__(self, db_driver=None):
39
db_driver = FLAGS.db_driver
40
self.db = importutils.import_module(db_driver) # pylint: disable=C0103