d8e0dc21e0
Add support to oslo.db to be used as a DB driver. The DB driver will be used with API v2. When it's completely implemented, API V1 will be deprecated and removed by the end of the cycle. Freezer-api will keep supporting V2 with Elasticsearch, Sqlalchemy drivers. This patch implements the follow: * Abstract Base DB driver to be implemented by each driver * Base driver; will return only access to the db engine, session * SqlAlchemy driver; * ElasticSearch driver; * Implement both drivers in freezer-manage Partially-Implements: blueprint oslo-db Depends-On: I81e417155da48f46dd2113e5745fb3c21c96499f Depends-On: I2e5724b1f1a75121952e2beb3844d2c489e4df68 Depends-On: Idb4ac050652d1d0107bf3fcd447d7cbedd811809 Depends-On: I81d46c89859752c0cbc21ef02de90db7f19f942c Change-Id: I93ed1b909f538728a1a9bd5c8b07baf7aeddb705
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
"""
|
|
(c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P.
|
|
(C) Copyright 2016-2018 Hewlett Packard Enterprise Development Company LP
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
"""
|
|
|
|
import abc
|
|
from oslo_config import cfg
|
|
from oslo_log import log
|
|
import six
|
|
|
|
CONF = cfg.CONF
|
|
LOG = log.getLogger(__name__)
|
|
|
|
|
|
@six.add_metaclass(abc.ABCMeta)
|
|
class DBDriver(object):
|
|
|
|
_OPTS = [
|
|
cfg.StrOpt('host',
|
|
required=True,
|
|
help="Database host"),
|
|
cfg.StrOpt("username",
|
|
help="Database username"),
|
|
cfg.StrOpt("password",
|
|
help="Database Password")
|
|
]
|
|
|
|
def __init__(self, backend, is_created=False):
|
|
if not is_created:
|
|
grp = cfg.OptGroup(backend)
|
|
CONF.register_group(grp)
|
|
CONF.register_opts(self._OPTS, grp)
|
|
self.conf = CONF.get(backend)
|
|
self.backend = backend
|
|
|
|
def connect(self):
|
|
pass
|
|
|
|
@abc.abstractproperty
|
|
def name(self):
|
|
"""Name of the database driver"""
|
|
pass
|
|
|
|
def get_instance(self):
|
|
pass
|