config options: improve help text of database (related) options (2/2)

This change introduces a group for the api database section and reuses
the help texts of the generic DB config opts. Appending API DB specific
help texts is also possible. As we copy the help texts, the pep8 check
which detects too short help texts has to be deactivated for that.

An alternative would have been to deepclone the generic DB config opts,
but that would make our lives harder when we need to deprecate those
cloned API DB opts.

bp centralize-config-options-newton

Change-Id: I7b74c4bb4a3edc335523c62ec63e57fdd5c51f39
This commit is contained in:
Markus Zoeller
2016-05-23 14:10:08 +02:00
parent d806972b85
commit bcd370331e

View File

@@ -1,10 +1,3 @@
# needs:fix_opt_description
# needs:check_deprecation_status
# needs:check_opt_group_and_type
# needs:fix_opt_description_indentation
# needs:fix_opt_registration_consistency
# Copyright 2015 OpenStack Foundation
# All Rights Reserved.
#
@@ -47,71 +40,105 @@ db_driver_opt = cfg.StrOpt(
# 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_group = cfg.OptGroup('api_database',
title='API Database Options',
help="""
The *Nova API Database* is a separate database which is used for information
which is used across *cells*. This database is mandatory since the Mitaka
release (13.0.0).
""")
api_db_opts = [
# TODO(markus_z): This should probably have a required=True attribute
cfg.StrOpt('connection',
help='The SQLAlchemy connection string to use to connect to '
'the Nova API database.',
secret=True),
secret=True,
help=''),
cfg.BoolOpt('sqlite_synchronous',
default=True,
help='If True, SQLite uses synchronous mode.'),
help=''),
cfg.StrOpt('slave_connection',
secret=True,
help='The SQLAlchemy connection string to use to connect to the'
' slave database.'),
help=''),
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='),
help=''),
cfg.IntOpt('idle_timeout',
default=3600,
help='Timeout before idle SQL connections are reaped.'),
help=''),
# TODO(markus_z): We should probably default this to 5 to not rely on the
# SQLAlchemy default. Otherwise we wouldn't provide a stable default.
cfg.IntOpt('max_pool_size',
help='Maximum number of SQL connections to keep open in a '
'pool.'),
help=''),
cfg.IntOpt('max_retries',
default=10,
help='Maximum number of database connection retries '
'during startup. Set to -1 to specify an infinite '
'retry count.'),
help=''),
# TODO(markus_z): This should have a minimum attribute of 0
cfg.IntOpt('retry_interval',
default=10,
help='Interval between retries of opening a SQL connection.'),
help=''),
# TODO(markus_z): We should probably default this to 10 to not rely on the
# SQLAlchemy default. Otherwise we wouldn't provide a stable default.
cfg.IntOpt('max_overflow',
help='If set, use this value for max_overflow with '
'SQLAlchemy.'),
help=''),
# TODO(markus_z): This should probably make use of the "choices" attribute.
# "oslo.db" uses only the values [<0, 0, 50, 100] see module
# /oslo_db/sqlalchemy/engines.py method "_setup_logging"
cfg.IntOpt('connection_debug',
default=0,
help='Verbosity of SQL debugging information: 0=None, '
'100=Everything.'),
help=''),
cfg.BoolOpt('connection_trace',
default=False,
help='Add Python stack traces to SQL as comment strings.'),
help=''),
# TODO(markus_z): We should probably default this to 30 to not rely on the
# SQLAlchemy default. Otherwise we wouldn't provide a stable default.
cfg.IntOpt('pool_timeout',
help='If set, use this value for pool_timeout with '
'SQLAlchemy.'),
]
help='')
] # noqa
def enrich_help_text(alt_db_opts):
def get_db_opts():
for group_name, db_opts in oslo_db_options.list_opts():
if group_name == 'database':
return db_opts
return []
for db_opt in get_db_opts():
for alt_db_opt in alt_db_opts:
if alt_db_opt.name == db_opt.name:
# NOTE(markus_z): We can append alternative DB specific help
# texts here if needed.
alt_db_opt.help = db_opt.help + alt_db_opt.help
def register_opts(conf):
oslo_db_options.set_defaults(conf, connection=_DEFAULT_SQL_CONNECTION,
sqlite_db='nova.sqlite')
sqlite_db='nova.sqlite')
conf.register_opt(db_driver_opt)
conf.register_opts(api_db_opts, group='api_database')
conf.register_opts(api_db_opts, group=api_db_group)
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.
# 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.
enrich_help_text(api_db_opts)
return {'DEFAULT': [db_driver_opt],
'api_database': api_db_opts,
api_db_group: api_db_opts,
}