Merge "Allow to specify data and lock apis with config"
This commit is contained in:
commit
e25d6605ff
|
@ -104,6 +104,33 @@ eventlet_opts = [
|
||||||
'wait forever.')),
|
'wait forever.')),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
data_api_opts = [
|
||||||
|
cfg.StrOpt('data_api',
|
||||||
|
default='glare.db.artifact_api.ArtifactAPI',
|
||||||
|
help=("""
|
||||||
|
Python class path of data access API.
|
||||||
|
|
||||||
|
Specifies the path to the API to use for accessing the data model.
|
||||||
|
This option determines how the artifact catalog data will be accessed.
|
||||||
|
|
||||||
|
If this option is set to ``glare.db.artifact_api.ArtifactAPI`` then
|
||||||
|
the artifact catalog data is stored in and read from the database via the
|
||||||
|
SQLAlchemy Core and ORM APIs.
|
||||||
|
""")),
|
||||||
|
cfg.StrOpt('lock_api',
|
||||||
|
default='glare.db.artifact_api.ArtifactLockApi',
|
||||||
|
help=("""
|
||||||
|
Python class path of API for setting locks on artifacts.
|
||||||
|
|
||||||
|
Specifies the path to the API to use for locking.
|
||||||
|
This option determines how the locking will be accessed.
|
||||||
|
|
||||||
|
If this option is set to ``glare.db.artifact_api.ArtifactLockApi``
|
||||||
|
then the locks are stored in and read from the database via the
|
||||||
|
SQLAlchemy Core and ORM APIs.
|
||||||
|
"""))
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -111,6 +138,7 @@ CONF = cfg.CONF
|
||||||
CONF.register_opts(bind_opts)
|
CONF.register_opts(bind_opts)
|
||||||
CONF.register_opts(socket_opts)
|
CONF.register_opts(socket_opts)
|
||||||
CONF.register_opts(eventlet_opts)
|
CONF.register_opts(eventlet_opts)
|
||||||
|
CONF.register_opts(data_api_opts)
|
||||||
profiler_opts.set_defaults(CONF)
|
profiler_opts.set_defaults(CONF)
|
||||||
|
|
||||||
ASYNC_EVENTLET_THREAD_POOL_LIST = []
|
ASYNC_EVENTLET_THREAD_POOL_LIST = []
|
||||||
|
|
|
@ -19,12 +19,12 @@ import jsonpatch
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from glare.common import exception
|
from glare.common import exception
|
||||||
from glare.common import policy
|
from glare.common import policy
|
||||||
from glare.common import store_api
|
from glare.common import store_api
|
||||||
from glare.common import utils
|
from glare.common import utils
|
||||||
from glare.db import artifact_api
|
|
||||||
from glare.i18n import _, _LI
|
from glare.i18n import _, _LI
|
||||||
from glare import locking
|
from glare import locking
|
||||||
from glare.notification import Notifier
|
from glare.notification import Notifier
|
||||||
|
@ -52,7 +52,7 @@ class Engine(object):
|
||||||
|
|
||||||
registry = glare_registry.ArtifactRegistry
|
registry = glare_registry.ArtifactRegistry
|
||||||
registry.register_all_artifacts()
|
registry.register_all_artifacts()
|
||||||
lock_engine = locking.LockEngine(artifact_api.ArtifactLockApi())
|
lock_engine = locking.LockEngine(importutils.import_class(CONF.lock_api)())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_schemas(cls, reg):
|
def _get_schemas(cls, reg):
|
||||||
|
|
|
@ -18,6 +18,7 @@ import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import importutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_versionedobjects import base
|
from oslo_versionedobjects import base
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
|
@ -27,7 +28,6 @@ import six.moves.urllib.request as urlrequest
|
||||||
from glare.common import exception
|
from glare.common import exception
|
||||||
from glare.common import store_api
|
from glare.common import store_api
|
||||||
from glare.common import utils
|
from glare.common import utils
|
||||||
from glare.db import artifact_api
|
|
||||||
from glare import locking
|
from glare import locking
|
||||||
from glare.i18n import _, _LI
|
from glare.i18n import _, _LI
|
||||||
from glare.objects.meta import attribute
|
from glare.objects.meta import attribute
|
||||||
|
@ -233,24 +233,14 @@ class BaseArtifact(base.VersionedObject):
|
||||||
|
|
||||||
_DB_API = None
|
_DB_API = None
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def init_db_api(cls):
|
|
||||||
"""Provide initialized db api to interact with artifact database.
|
|
||||||
|
|
||||||
To interact with database each artifact type must provide an api
|
|
||||||
to execute db operations with artifacts.
|
|
||||||
:return: subtype of glare.db.api.BaseDBAPI
|
|
||||||
"""
|
|
||||||
return artifact_api.ArtifactAPI(cls)
|
|
||||||
|
|
||||||
@classproperty
|
@classproperty
|
||||||
def db_api(cls):
|
def db_api(cls):
|
||||||
"""Return current database API"""
|
"""Return current database API"""
|
||||||
if cls._DB_API is None:
|
if cls._DB_API is None:
|
||||||
cls._DB_API = cls.init_db_api()
|
cls._DB_API = importutils.import_class(CONF.data_api)(cls)
|
||||||
return cls._DB_API
|
return cls._DB_API
|
||||||
|
|
||||||
lock_engine = locking.LockEngine(artifact_api.ArtifactLockApi())
|
lock_engine = locking.LockEngine(importutils.import_class(CONF.lock_api)())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _lock_version(cls, context, values):
|
def _lock_version(cls, context, values):
|
||||||
|
|
|
@ -37,6 +37,7 @@ _artifacts_opts = [
|
||||||
glare.api.versions.versions_opts,
|
glare.api.versions.versions_opts,
|
||||||
glare.common.config.common_opts,
|
glare.common.config.common_opts,
|
||||||
glare.common.wsgi.bind_opts,
|
glare.common.wsgi.bind_opts,
|
||||||
|
glare.common.wsgi.data_api_opts,
|
||||||
glare.common.wsgi.eventlet_opts,
|
glare.common.wsgi.eventlet_opts,
|
||||||
glare.common.wsgi.socket_opts,
|
glare.common.wsgi.socket_opts,
|
||||||
glare.notification.notifier_opts,
|
glare.notification.notifier_opts,
|
||||||
|
|
Loading…
Reference in New Issue