Centralize config option: database section
Centralize config option of database section. Replace oslo_conf cfg to magnum.conf. Change-Id: Id12bbf3ad8d3342450cd64cf23761a60d49ee46a Implements: blueprint centralize-config-magnum
This commit is contained in:
parent
e4627ab6dd
commit
d86b5735cd
@ -23,7 +23,7 @@ from magnum.conf import cluster
|
|||||||
from magnum.conf import cluster_heat
|
from magnum.conf import cluster_heat
|
||||||
from magnum.conf import cluster_templates
|
from magnum.conf import cluster_templates
|
||||||
from magnum.conf import conductor
|
from magnum.conf import conductor
|
||||||
# from magnum.conf import database
|
from magnum.conf import database
|
||||||
# from magnum.conf import docker
|
# from magnum.conf import docker
|
||||||
from magnum.conf import glance
|
from magnum.conf import glance
|
||||||
from magnum.conf import heat
|
from magnum.conf import heat
|
||||||
@ -44,7 +44,7 @@ cluster_heat.register_opts(CONF)
|
|||||||
# certificates.register_opts(CONF)
|
# certificates.register_opts(CONF)
|
||||||
cinder.register_opts(CONF)
|
cinder.register_opts(CONF)
|
||||||
conductor.register_opts(CONF)
|
conductor.register_opts(CONF)
|
||||||
# database.register_opts(CONF)
|
database.register_opts(CONF)
|
||||||
# docker.register_opts(CONF)
|
# docker.register_opts(CONF)
|
||||||
glance.register_opts(CONF)
|
glance.register_opts(CONF)
|
||||||
heat.register_opts(CONF)
|
heat.register_opts(CONF)
|
||||||
|
40
magnum/conf/database.py
Normal file
40
magnum/conf/database.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_db import options
|
||||||
|
|
||||||
|
from magnum.conf import paths
|
||||||
|
|
||||||
|
|
||||||
|
_DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('magnum.sqlite')
|
||||||
|
|
||||||
|
database_group = cfg.OptGroup(name='database',
|
||||||
|
title='Options for Magnum Database')
|
||||||
|
|
||||||
|
sql_opts = [
|
||||||
|
cfg.StrOpt('mysql_engine',
|
||||||
|
default='InnoDB',
|
||||||
|
help='MySQL engine to use.')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def register_opts(conf):
|
||||||
|
conf.register_group(database_group)
|
||||||
|
conf.register_opts(sql_opts, group=database_group)
|
||||||
|
options.set_defaults(conf, _DEFAULT_SQL_CONNECTION, 'magnum.sqlite')
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
return {
|
||||||
|
database_group: sql_opts
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
# Copyright 2015 NEC Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_db import options
|
|
||||||
|
|
||||||
from magnum.conf import paths
|
|
||||||
|
|
||||||
|
|
||||||
sql_opts = [
|
|
||||||
cfg.StrOpt('mysql_engine',
|
|
||||||
default='InnoDB',
|
|
||||||
help='MySQL engine to use.')
|
|
||||||
]
|
|
||||||
|
|
||||||
_DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('magnum.sqlite')
|
|
||||||
|
|
||||||
|
|
||||||
cfg.CONF.register_opts(sql_opts, 'database')
|
|
||||||
options.set_defaults(cfg.CONF, _DEFAULT_SQL_CONNECTION, 'magnum.sqlite')
|
|
@ -16,18 +16,19 @@
|
|||||||
|
|
||||||
"""Database setup and migration commands."""
|
"""Database setup and migration commands."""
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from stevedore import driver
|
from stevedore import driver
|
||||||
|
|
||||||
|
import magnum.conf
|
||||||
|
|
||||||
|
CONF = magnum.conf.CONF
|
||||||
_IMPL = None
|
_IMPL = None
|
||||||
|
|
||||||
|
|
||||||
def get_backend():
|
def get_backend():
|
||||||
global _IMPL
|
global _IMPL
|
||||||
if not _IMPL:
|
if not _IMPL:
|
||||||
cfg.CONF.import_opt('backend', 'oslo_db.options', group='database')
|
|
||||||
_IMPL = driver.DriverManager("magnum.database.migration_backend",
|
_IMPL = driver.DriverManager("magnum.database.migration_backend",
|
||||||
cfg.CONF.database.backend).driver
|
CONF.database.backend).driver
|
||||||
return _IMPL
|
return _IMPL
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
"""SQLAlchemy storage backend."""
|
"""SQLAlchemy storage backend."""
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
from oslo_db.sqlalchemy import session as db_session
|
from oslo_db.sqlalchemy import session as db_session
|
||||||
from oslo_db.sqlalchemy import utils as db_utils
|
from oslo_db.sqlalchemy import utils as db_utils
|
||||||
@ -25,11 +24,12 @@ from sqlalchemy.orm.exc import MultipleResultsFound
|
|||||||
from sqlalchemy.orm.exc import NoResultFound
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from magnum.common import exception
|
from magnum.common import exception
|
||||||
|
import magnum.conf
|
||||||
from magnum.db import api
|
from magnum.db import api
|
||||||
from magnum.db.sqlalchemy import models
|
from magnum.db.sqlalchemy import models
|
||||||
from magnum.i18n import _
|
from magnum.i18n import _
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = magnum.conf.CONF
|
||||||
|
|
||||||
|
|
||||||
_FACADE = None
|
_FACADE = None
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_db.sqlalchemy.migration_cli import manager
|
from oslo_db.sqlalchemy.migration_cli import manager
|
||||||
|
|
||||||
|
import magnum.conf
|
||||||
|
|
||||||
|
CONF = magnum.conf.CONF
|
||||||
_MANAGER = None
|
_MANAGER = None
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ def get_manager():
|
|||||||
os.path.join(os.path.dirname(__file__), 'alembic'))
|
os.path.join(os.path.dirname(__file__), 'alembic'))
|
||||||
migration_config = {'alembic_ini_path': alembic_path,
|
migration_config = {'alembic_ini_path': alembic_path,
|
||||||
'alembic_repo_path': migrate_path,
|
'alembic_repo_path': migrate_path,
|
||||||
'db_url': cfg.CONF.database.connection}
|
'db_url': CONF.database.connection}
|
||||||
_MANAGER = manager.MigrationManager(migration_config)
|
_MANAGER = manager.MigrationManager(migration_config)
|
||||||
|
|
||||||
return _MANAGER
|
return _MANAGER
|
||||||
|
@ -18,7 +18,6 @@ SQLAlchemy models for container service
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
from sqlalchemy import Boolean
|
from sqlalchemy import Boolean
|
||||||
@ -31,13 +30,16 @@ from sqlalchemy import String
|
|||||||
from sqlalchemy import Text
|
from sqlalchemy import Text
|
||||||
from sqlalchemy.types import TypeDecorator, TEXT
|
from sqlalchemy.types import TypeDecorator, TEXT
|
||||||
|
|
||||||
|
import magnum.conf
|
||||||
from magnum.i18n import _LE
|
from magnum.i18n import _LE
|
||||||
|
|
||||||
|
CONF = magnum.conf.CONF
|
||||||
|
|
||||||
|
|
||||||
def table_args():
|
def table_args():
|
||||||
engine_name = urlparse.urlparse(cfg.CONF.database.connection).scheme
|
engine_name = urlparse.urlparse(CONF.database.connection).scheme
|
||||||
if engine_name == 'mysql':
|
if engine_name == 'mysql':
|
||||||
return {'mysql_engine': cfg.CONF.database.mysql_engine,
|
return {'mysql_engine': CONF.database.mysql_engine,
|
||||||
'mysql_charset': "utf8"}
|
'mysql_charset': "utf8"}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ def list_opts():
|
|||||||
magnum.common.rpc_service.periodic_opts,
|
magnum.common.rpc_service.periodic_opts,
|
||||||
magnum.common.service.service_opts,
|
magnum.common.service.service_opts,
|
||||||
)),
|
)),
|
||||||
('database', magnum.db.sql_opts),
|
|
||||||
('docker', magnum.common.docker_utils.docker_opts),
|
('docker', magnum.common.docker_utils.docker_opts),
|
||||||
('trust', magnum.common.keystone.trust_opts),
|
('trust', magnum.common.keystone.trust_opts),
|
||||||
('x509', magnum.common.x509.config.x509_opts),
|
('x509', magnum.common.x509.config.x509_opts),
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
"""Magnum DB test base class."""
|
"""Magnum DB test base class."""
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo_config import cfg
|
|
||||||
|
|
||||||
|
import magnum.conf
|
||||||
from magnum.db import api as dbapi
|
from magnum.db import api as dbapi
|
||||||
from magnum.db.sqlalchemy import api as sqla_api
|
from magnum.db.sqlalchemy import api as sqla_api
|
||||||
from magnum.db.sqlalchemy import migration
|
from magnum.db.sqlalchemy import migration
|
||||||
@ -25,7 +25,7 @@ from magnum.db.sqlalchemy import models
|
|||||||
from magnum.tests import base
|
from magnum.tests import base
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = magnum.conf.CONF
|
||||||
|
|
||||||
_DB_CACHE = None
|
_DB_CACHE = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user