config options: centralize section "database" + "api_database"
The config options of the "nova.conf" section "database" and "api_database" got moved to the new central location "nova/conf/database.py". Also the database related options which are in DEFAULT section. Follow up changes will improve the help texts. bp centralize-config-options-newton Change-Id: Iaba9b49490fea4950bb25eed3ba1252db206f3c9
This commit is contained in:
parent
9a05d38f48
commit
2811ff43af
@ -37,7 +37,7 @@ from nova.conf import consoleauth
|
||||
# from nova.conf import cors
|
||||
# from nova.conf import cors.subdomain
|
||||
from nova.conf import crypto
|
||||
# from nova.conf import database
|
||||
from nova.conf import database
|
||||
# from nova.conf import disk
|
||||
from nova.conf import ephemeral_storage
|
||||
from nova.conf import floating_ips
|
||||
@ -110,7 +110,7 @@ consoleauth.register_opts(CONF)
|
||||
# cors.register_opts(CONF)
|
||||
# cors.subdomain.register_opts(CONF)
|
||||
crypto.register_opts(CONF)
|
||||
# database.register_opts(CONF)
|
||||
database.register_opts(CONF)
|
||||
# disk.register_opts(CONF)
|
||||
ephemeral_storage.register_opts(CONF)
|
||||
floating_ips.register_opts(CONF)
|
||||
|
@ -309,6 +309,23 @@ whenever an RPC call to the compute service is made.
|
||||
"""),
|
||||
]
|
||||
|
||||
db_opts = [
|
||||
cfg.StrOpt('osapi_compute_unique_server_name_scope',
|
||||
default='',
|
||||
help='When set, compute API will consider duplicate hostnames '
|
||||
'invalid within the specified scope, regardless of case. '
|
||||
'Should be empty, "project" or "global".'),
|
||||
cfg.BoolOpt('enable_new_services',
|
||||
default=True,
|
||||
help='Services to be added to the available pool on create'),
|
||||
cfg.StrOpt('instance_name_template',
|
||||
default='instance-%08x',
|
||||
help='Template string to be used to generate instance names'),
|
||||
cfg.StrOpt('snapshot_name_template',
|
||||
default='snapshot-%s',
|
||||
help='Template string to be used to generate snapshot names'),
|
||||
]
|
||||
|
||||
ALL_OPTS = list(itertools.chain(
|
||||
compute_opts,
|
||||
resource_tracker_opts,
|
||||
@ -319,6 +336,7 @@ ALL_OPTS = list(itertools.chain(
|
||||
running_deleted_opts,
|
||||
instance_cleaning_opts,
|
||||
rpcapi_opts,
|
||||
db_opts,
|
||||
))
|
||||
|
||||
|
||||
|
106
nova/conf/database.py
Normal file
106
nova/conf/database.py
Normal file
@ -0,0 +1,106 @@
|
||||
# Copyright 2015 OpenStack Foundation
|
||||
# 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 as oslo_db_options
|
||||
|
||||
|
||||
# NOTE(sdague): we know of at least 1 instance of out of tree usage
|
||||
# for this config in RAX. They used this because of performance issues
|
||||
# with some queries. We think the right path forward is fixing the
|
||||
# SQLA queries to be more performant for everyone.
|
||||
db_driver_opt = cfg.StrOpt(
|
||||
'db_driver',
|
||||
default='nova.db',
|
||||
help='DEPRECATED: The driver to use for database access',
|
||||
deprecated_for_removal=True)
|
||||
|
||||
|
||||
# NOTE(markus_z): We cannot simply do:
|
||||
# conf.register_opts(oslo_db_options.database_opts, 'api_database')
|
||||
# If we reuse a db config option for two different groups ("api_database"
|
||||
# and "database") and deprecate or rename a config option in one of these
|
||||
# groups, "oslo.config" cannot correctly determine which one to update.
|
||||
# That's why we copied & pasted these config options for the "api_database"
|
||||
# group here. See commit ba407e3 ("Add support for multiple database engines")
|
||||
# for more details.
|
||||
api_db_opts = [
|
||||
cfg.StrOpt('connection',
|
||||
help='The SQLAlchemy connection string to use to connect to '
|
||||
'the Nova API database.',
|
||||
secret=True),
|
||||
cfg.BoolOpt('sqlite_synchronous',
|
||||
default=True,
|
||||
help='If True, SQLite uses synchronous mode.'),
|
||||
cfg.StrOpt('slave_connection',
|
||||
secret=True,
|
||||
help='The SQLAlchemy connection string to use to connect to the'
|
||||
' slave database.'),
|
||||
cfg.StrOpt('mysql_sql_mode',
|
||||
default='TRADITIONAL',
|
||||
help='The SQL mode to be used for MySQL sessions. '
|
||||
'This option, including the default, overrides any '
|
||||
'server-set SQL mode. To use whatever SQL mode '
|
||||
'is set by the server configuration, '
|
||||
'set this to no value. Example: mysql_sql_mode='),
|
||||
cfg.IntOpt('idle_timeout',
|
||||
default=3600,
|
||||
help='Timeout before idle SQL connections are reaped.'),
|
||||
cfg.IntOpt('max_pool_size',
|
||||
help='Maximum number of SQL connections to keep open in a '
|
||||
'pool.'),
|
||||
cfg.IntOpt('max_retries',
|
||||
default=10,
|
||||
help='Maximum number of database connection retries '
|
||||
'during startup. Set to -1 to specify an infinite '
|
||||
'retry count.'),
|
||||
cfg.IntOpt('retry_interval',
|
||||
default=10,
|
||||
help='Interval between retries of opening a SQL connection.'),
|
||||
cfg.IntOpt('max_overflow',
|
||||
help='If set, use this value for max_overflow with '
|
||||
'SQLAlchemy.'),
|
||||
cfg.IntOpt('connection_debug',
|
||||
default=0,
|
||||
help='Verbosity of SQL debugging information: 0=None, '
|
||||
'100=Everything.'),
|
||||
cfg.BoolOpt('connection_trace',
|
||||
default=False,
|
||||
help='Add Python stack traces to SQL as comment strings.'),
|
||||
cfg.IntOpt('pool_timeout',
|
||||
help='If set, use this value for pool_timeout with '
|
||||
'SQLAlchemy.'),
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_opts(oslo_db_options.database_opts, 'database')
|
||||
conf.register_opt(db_driver_opt)
|
||||
conf.register_opts(api_db_opts, group='api_database')
|
||||
|
||||
|
||||
def list_opts():
|
||||
# NOTE(markus_z): 2016-04-04: If we list the oslo_db_options here, they
|
||||
# get emitted twice(!) in the "sample.conf" file. First
|
||||
# under the namespace "nova.conf" and second under the
|
||||
# namespace "oslo.db". This is due to the setting in file
|
||||
# "etc/nova/nova-config-generator.conf". As I think it
|
||||
# is useful to have the "oslo.db" namespace information
|
||||
# in the "sample.conf" file, I omit the listing of the
|
||||
# "oslo_db_options" here.
|
||||
return {'DEFAULT': [db_driver_opt],
|
||||
'api_database': api_db_opts,
|
||||
}
|
@ -27,28 +27,15 @@ these objects be simple dictionaries.
|
||||
|
||||
"""
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import concurrency
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova.cells import rpcapi as cells_rpcapi
|
||||
import nova.conf
|
||||
from nova.i18n import _LE
|
||||
|
||||
|
||||
db_opts = [
|
||||
cfg.BoolOpt('enable_new_services',
|
||||
default=True,
|
||||
help='Services to be added to the available pool on create'),
|
||||
cfg.StrOpt('instance_name_template',
|
||||
default='instance-%08x',
|
||||
help='Template string to be used to generate instance names'),
|
||||
cfg.StrOpt('snapshot_name_template',
|
||||
default='snapshot-%s',
|
||||
help='Template string to be used to generate snapshot names'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(db_opts)
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
_BACKEND_MAPPING = {'sqlalchemy': 'nova.db.sqlalchemy.api'}
|
||||
|
||||
|
@ -16,22 +16,12 @@
|
||||
|
||||
"""Base class for classes that need modular database access."""
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import importutils
|
||||
|
||||
# NOTE(sdague): we know of at least 1 instance of out of tree usage
|
||||
# for this config in RAX. They used this because of performance issues
|
||||
# with some queries. We think the right path forward is fixing the
|
||||
# SQLA queries to be more performant for everyone.
|
||||
db_driver_opt = cfg.StrOpt(
|
||||
'db_driver',
|
||||
default='nova.db',
|
||||
help='DEPRECATED: The driver to use for database access',
|
||||
deprecated_for_removal=True)
|
||||
import nova.conf
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opt(db_driver_opt)
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
||||
class Base(object):
|
||||
|
@ -25,10 +25,8 @@ import inspect
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_db import options as oslo_db_options
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import update_match
|
||||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||
@ -70,66 +68,9 @@ from nova.objects import fields
|
||||
from nova import quota
|
||||
from nova import safe_utils
|
||||
|
||||
db_opts = [
|
||||
cfg.StrOpt('osapi_compute_unique_server_name_scope',
|
||||
default='',
|
||||
help='When set, compute API will consider duplicate hostnames '
|
||||
'invalid within the specified scope, regardless of case. '
|
||||
'Should be empty, "project" or "global".'),
|
||||
]
|
||||
|
||||
api_db_opts = [
|
||||
cfg.StrOpt('connection',
|
||||
help='The SQLAlchemy connection string to use to connect to '
|
||||
'the Nova API database.',
|
||||
secret=True),
|
||||
cfg.BoolOpt('sqlite_synchronous',
|
||||
default=True,
|
||||
help='If True, SQLite uses synchronous mode.'),
|
||||
cfg.StrOpt('slave_connection',
|
||||
secret=True,
|
||||
help='The SQLAlchemy connection string to use to connect to the'
|
||||
' slave database.'),
|
||||
cfg.StrOpt('mysql_sql_mode',
|
||||
default='TRADITIONAL',
|
||||
help='The SQL mode to be used for MySQL sessions. '
|
||||
'This option, including the default, overrides any '
|
||||
'server-set SQL mode. To use whatever SQL mode '
|
||||
'is set by the server configuration, '
|
||||
'set this to no value. Example: mysql_sql_mode='),
|
||||
cfg.IntOpt('idle_timeout',
|
||||
default=3600,
|
||||
help='Timeout before idle SQL connections are reaped.'),
|
||||
cfg.IntOpt('max_pool_size',
|
||||
help='Maximum number of SQL connections to keep open in a '
|
||||
'pool.'),
|
||||
cfg.IntOpt('max_retries',
|
||||
default=10,
|
||||
help='Maximum number of database connection retries '
|
||||
'during startup. Set to -1 to specify an infinite '
|
||||
'retry count.'),
|
||||
cfg.IntOpt('retry_interval',
|
||||
default=10,
|
||||
help='Interval between retries of opening a SQL connection.'),
|
||||
cfg.IntOpt('max_overflow',
|
||||
help='If set, use this value for max_overflow with '
|
||||
'SQLAlchemy.'),
|
||||
cfg.IntOpt('connection_debug',
|
||||
default=0,
|
||||
help='Verbosity of SQL debugging information: 0=None, '
|
||||
'100=Everything.'),
|
||||
cfg.BoolOpt('connection_trace',
|
||||
default=False,
|
||||
help='Add Python stack traces to SQL as comment strings.'),
|
||||
cfg.IntOpt('pool_timeout',
|
||||
help='If set, use this value for pool_timeout with '
|
||||
'SQLAlchemy.'),
|
||||
]
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
CONF.register_opts(db_opts)
|
||||
CONF.register_opts(oslo_db_options.database_opts, 'database')
|
||||
CONF.register_opts(api_db_opts, group='api_database')
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -21,9 +21,6 @@ import nova.conf
|
||||
import nova.console.rpcapi
|
||||
import nova.console.serial
|
||||
import nova.consoleauth.rpcapi
|
||||
import nova.db.api
|
||||
import nova.db.base
|
||||
import nova.db.sqlalchemy.api
|
||||
import nova.exception
|
||||
import nova.image.download.file
|
||||
import nova.volume
|
||||
@ -33,12 +30,7 @@ def list_opts():
|
||||
return [
|
||||
('DEFAULT',
|
||||
itertools.chain(
|
||||
[nova.db.base.db_driver_opt],
|
||||
nova.db.api.db_opts,
|
||||
nova.db.sqlalchemy.api.db_opts,
|
||||
nova.exception.exc_log_opts,
|
||||
nova.volume._volume_opts,
|
||||
)),
|
||||
('api_database', nova.db.sqlalchemy.api.api_db_opts),
|
||||
('database', nova.db.sqlalchemy.api.oslo_db_options.database_opts),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user