Make use of oslo-config-generator

Change-Id: I43455aa3d13bd8310f7de94b76dfd7ddd2080516
This commit is contained in:
Zhenguo Niu 2016-08-17 00:51:20 +08:00
parent 698c4fb207
commit 74444bd30e
8 changed files with 613 additions and 0 deletions

View File

@ -1 +1,481 @@
[DEFAULT]
#
# From nimble
#
# Used if there is a formatting error when generating an
# exception message (a programming error). If True, raise an
# exception; if False, use the unformatted message. (boolean
# value)
#fatal_exception_format_errors = false
# Directory where the nimble python module is installed.
# (string value)
#pybasedir = /usr/lib/python/site-packages/nimble/nimble
# Directory where nimble binaries are installed. (string
# value)
#bindir = $pybasedir/bin
# Top-level directory for maintaining nimble's state. (string
# value)
#state_path = $pybasedir
# Name of this node. This can be an opaque identifier. It is
# not necessarily a hostname, FQDN, or IP address. However,
# the node name must be valid within an AMQP key, and if using
# ZeroMQ, a valid hostname, FQDN, or IP address. (string
# value)
#host = localhost
#
# From oslo.log
#
# If set to true, the logging level will be set to DEBUG
# instead of the default INFO level. (boolean value)
# Note: This option can be changed without restarting.
#debug = false
# DEPRECATED: If set to false, the logging level will be set
# to WARNING instead of the default INFO level. (boolean
# value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#verbose = true
# The name of a logging configuration file. This file is
# appended to any existing logging configuration files. For
# details about logging configuration files, see the Python
# logging module documentation. Note that when logging
# configuration files are used then all logging configuration
# is set in the configuration file and other logging
# configuration options are ignored (for example,
# logging_context_format_string). (string value)
# Note: This option can be changed without restarting.
# Deprecated group/name - [DEFAULT]/log_config
#log_config_append = <None>
# Defines the format string for %%(asctime)s in log records.
# Default: %(default)s . This option is ignored if
# log_config_append is set. (string value)
#log_date_format = %Y-%m-%d %H:%M:%S
# (Optional) Name of log file to send logging output to. If no
# default is set, logging will go to stderr as defined by
# use_stderr. This option is ignored if log_config_append is
# set. (string value)
# Deprecated group/name - [DEFAULT]/logfile
#log_file = <None>
# (Optional) The base directory used for relative log_file
# paths. This option is ignored if log_config_append is set.
# (string value)
# Deprecated group/name - [DEFAULT]/logdir
#log_dir = <None>
# Uses logging handler designed to watch file system. When log
# file is moved or removed this handler will open a new log
# file with specified path instantaneously. It makes sense
# only if log_file option is specified and Linux platform is
# used. This option is ignored if log_config_append is set.
# (boolean value)
#watch_log_file = false
# Use syslog for logging. Existing syslog format is DEPRECATED
# and will be changed later to honor RFC5424. This option is
# ignored if log_config_append is set. (boolean value)
#use_syslog = false
# Syslog facility to receive log lines. This option is ignored
# if log_config_append is set. (string value)
#syslog_log_facility = LOG_USER
# Log output to standard error. This option is ignored if
# log_config_append is set. (boolean value)
#use_stderr = true
# Format string to use for log messages with context. (string
# value)
#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
# Format string to use for log messages when context is
# undefined. (string value)
#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
# Additional data to append to log message when logging level
# for the message is DEBUG. (string value)
#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d
# Prefix each line of exception output with this format.
# (string value)
#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
# Defines the format string for %(user_identity)s that is used
# in logging_context_format_string. (string value)
#logging_user_identity_format = %(user)s %(tenant)s %(domain)s %(user_domain)s %(project_domain)s
# List of package logging levels in logger=LEVEL pairs. This
# option is ignored if log_config_append is set. (list value)
#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN,taskflow=WARN,keystoneauth=WARN,oslo.cache=INFO,dogpile.core.dogpile=INFO
# Enables or disables publication of error events. (boolean
# value)
#publish_errors = false
# The format for an instance that is passed with the log
# message. (string value)
#instance_format = "[instance: %(uuid)s] "
# The format for an instance UUID that is passed with the log
# message. (string value)
#instance_uuid_format = "[instance: %(uuid)s] "
# Enables or disables fatal status of deprecations. (boolean
# value)
#fatal_deprecations = false
#
# From oslo.service.periodic_task
#
# Some periodic tasks can be run in a separate process. Should
# we run them here? (boolean value)
#run_external_periodic_tasks = true
#
# From oslo.service.service
#
# Enable eventlet backdoor. Acceptable values are 0, <port>,
# and <start>:<end>, where 0 results in listening on a random
# tcp port number; <port> results in listening on the
# specified port number (and not enabling backdoor if that
# port is in use); and <start>:<end> results in listening on
# the smallest unused port number within the specified range
# of port numbers. The chosen port is displayed in the
# service's log file. (string value)
#backdoor_port = <None>
# Enable eventlet backdoor, using the provided path as a unix
# socket that can receive connections. This option is mutually
# exclusive with 'backdoor_port' in that only one should be
# provided. If both are provided then the existence of this
# option overrides the usage of that option. (string value)
#backdoor_socket = <None>
# Enables or disables logging values of all registered options
# when starting a service (at DEBUG level). (boolean value)
#log_options = true
# Specify a timeout after which a gracefully shutdown server
# will exit. Zero value means endless wait. (integer value)
#graceful_shutdown_timeout = 60
[api]
#
# From nimble
#
# The IP address on which nimble-api listens. (string value)
#host_ip = 0.0.0.0
# The TCP port on which nimble-api listens. (port value)
# Minimum value: 0
# Maximum value: 65535
#port = 6688
# The maximum number of items returned in a single response
# from a collection resource. (integer value)
#max_limit = 1000
# Public URL to use when building the links to the API
# resources (for example, "https://nimble.rocks:6688"). If
# None the links will be built using the request's host URL.
# If the API is operating behind a proxy, you will want to
# change this to represent the proxy's URL. Defaults to None.
# (string value)
#public_endpoint = <None>
# Number of workers for OpenStack Nimble API service. The
# default is equal to the number of CPUs available if that can
# be determined, else a default worker count of 1 is returned.
# (integer value)
#api_workers = <None>
# Enable the integrated stand-alone API to service requests
# via HTTPS instead of HTTP. If there is a front-end service
# performing HTTPS offloading from the service, this option
# should be False; note, you will want to change public API
# endpoint to represent SSL termination URL with
# 'public_endpoint' option. (boolean value)
#enable_ssl_api = false
[cors]
#
# From oslo.middleware.cors
#
# Indicate whether this resource may be shared with the domain
# received in the requests "origin" header. Format:
# "<protocol>://<host>[:<port>]", no trailing slash. Example:
# https://horizon.example.com (list value)
#allowed_origin = <None>
# Indicate that the actual request can include user
# credentials (boolean value)
#allow_credentials = true
# Indicate which headers are safe to expose to the API.
# Defaults to HTTP Simple Headers. (list value)
#expose_headers =
# Maximum cache age of CORS preflight requests. (integer
# value)
#max_age = 3600
# Indicate which methods can be used during the actual
# request. (list value)
#allow_methods = OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,PATCH
# Indicate which header field names may be used during the
# actual request. (list value)
#allow_headers =
[cors.subdomain]
#
# From oslo.middleware.cors
#
# Indicate whether this resource may be shared with the domain
# received in the requests "origin" header. Format:
# "<protocol>://<host>[:<port>]", no trailing slash. Example:
# https://horizon.example.com (list value)
#allowed_origin = <None>
# Indicate that the actual request can include user
# credentials (boolean value)
#allow_credentials = true
# Indicate which headers are safe to expose to the API.
# Defaults to HTTP Simple Headers. (list value)
#expose_headers =
# Maximum cache age of CORS preflight requests. (integer
# value)
#max_age = 3600
# Indicate which methods can be used during the actual
# request. (list value)
#allow_methods = OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,PATCH
# Indicate which header field names may be used during the
# actual request. (list value)
#allow_headers =
[database]
#
# From nimble
#
# MySQL engine to use. (string value)
#mysql_engine = InnoDB
#
# From oslo.db
#
# DEPRECATED: The file name to use with SQLite. (string value)
# Deprecated group/name - [DEFAULT]/sqlite_db
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
# Reason: Should use config option connection or
# slave_connection to connect the database.
#sqlite_db = oslo.sqlite
# If True, SQLite uses synchronous mode. (boolean value)
# Deprecated group/name - [DEFAULT]/sqlite_synchronous
#sqlite_synchronous = true
# The back end to use for the database. (string value)
# Deprecated group/name - [DEFAULT]/db_backend
#backend = sqlalchemy
# The SQLAlchemy connection string to use to connect to the
# database. (string value)
# Deprecated group/name - [DEFAULT]/sql_connection
# Deprecated group/name - [DATABASE]/sql_connection
# Deprecated group/name - [sql]/connection
#connection = <None>
# The SQLAlchemy connection string to use to connect to the
# slave database. (string value)
#slave_connection = <None>
# 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= (string
# value)
#mysql_sql_mode = TRADITIONAL
# Timeout before idle SQL connections are reaped. (integer
# value)
# Deprecated group/name - [DEFAULT]/sql_idle_timeout
# Deprecated group/name - [DATABASE]/sql_idle_timeout
# Deprecated group/name - [sql]/idle_timeout
#idle_timeout = 3600
# Minimum number of SQL connections to keep open in a pool.
# (integer value)
# Deprecated group/name - [DEFAULT]/sql_min_pool_size
# Deprecated group/name - [DATABASE]/sql_min_pool_size
#min_pool_size = 1
# Maximum number of SQL connections to keep open in a pool.
# Setting a value of 0 indicates no limit. (integer value)
# Deprecated group/name - [DEFAULT]/sql_max_pool_size
# Deprecated group/name - [DATABASE]/sql_max_pool_size
#max_pool_size = 5
# Maximum number of database connection retries during
# startup. Set to -1 to specify an infinite retry count.
# (integer value)
# Deprecated group/name - [DEFAULT]/sql_max_retries
# Deprecated group/name - [DATABASE]/sql_max_retries
#max_retries = 10
# Interval between retries of opening a SQL connection.
# (integer value)
# Deprecated group/name - [DEFAULT]/sql_retry_interval
# Deprecated group/name - [DATABASE]/reconnect_interval
#retry_interval = 10
# If set, use this value for max_overflow with SQLAlchemy.
# (integer value)
# Deprecated group/name - [DEFAULT]/sql_max_overflow
# Deprecated group/name - [DATABASE]/sqlalchemy_max_overflow
#max_overflow = 50
# Verbosity of SQL debugging information: 0=None,
# 100=Everything. (integer value)
# Minimum value: 0
# Maximum value: 100
# Deprecated group/name - [DEFAULT]/sql_connection_debug
#connection_debug = 0
# Add Python stack traces to SQL as comment strings. (boolean
# value)
# Deprecated group/name - [DEFAULT]/sql_connection_trace
#connection_trace = false
# If set, use this value for pool_timeout with SQLAlchemy.
# (integer value)
# Deprecated group/name - [DATABASE]/sqlalchemy_pool_timeout
#pool_timeout = <None>
# Enable the experimental use of database reconnect on
# connection lost. (boolean value)
#use_db_reconnect = false
# Seconds between retries of a database transaction. (integer
# value)
#db_retry_interval = 1
# If True, increases the interval between retries of a
# database operation up to db_max_retry_interval. (boolean
# value)
#db_inc_retry_interval = true
# If db_inc_retry_interval is set, the maximum seconds between
# retries of a database operation. (integer value)
#db_max_retry_interval = 10
# Maximum retries in case of connection error or deadlock
# error before error is raised. Set to -1 to specify an
# infinite retry count. (integer value)
#db_max_retries = 20
[oslo_concurrency]
#
# From oslo.concurrency
#
# Enables or disables inter-process locks. (boolean value)
# Deprecated group/name - [DEFAULT]/disable_process_locking
#disable_process_locking = false
# Directory to use for lock files. For security, the
# specified directory should only be writable by the user
# running the processes that need locking. Defaults to
# environment variable OSLO_LOCK_PATH. If external locks are
# used, a lock path must be set. (string value)
# Deprecated group/name - [DEFAULT]/lock_path
#lock_path = <None>
[oslo_policy]
#
# From oslo.policy
#
# The JSON file that defines policies. (string value)
# Deprecated group/name - [DEFAULT]/policy_file
#policy_file = policy.json
# Default rule. Enforced when a requested rule is not found.
# (string value)
# Deprecated group/name - [DEFAULT]/policy_default_rule
#policy_default_rule = default
# Directories where policy configuration files are stored.
# They can be relative to any directory in the search path
# defined by the config_dir option, or absolute paths. The
# file defined by policy_file must exist for these directories
# to be searched. Missing or empty directories are ignored.
# (multi valued)
# Deprecated group/name - [DEFAULT]/policy_dirs
#policy_dirs = policy.d
[ssl]
#
# From oslo.service.sslutils
#
# CA certificate file to use to verify connecting clients.
# (string value)
# Deprecated group/name - [DEFAULT]/ssl_ca_file
#ca_file = <None>
# Certificate file to use when starting the server securely.
# (string value)
# Deprecated group/name - [DEFAULT]/ssl_cert_file
#cert_file = <None>
# Private key file to use when starting the server securely.
# (string value)
# Deprecated group/name - [DEFAULT]/ssl_key_file
#key_file = <None>
# SSL version to use (valid only if SSL enabled). Valid values
# are TLSv1 and SSLv23. SSLv2, SSLv3, TLSv1_1, and TLSv1_2 may
# be available on some distributions. (string value)
#version = <None>
# Sets the list of available ciphers. value should be a string
# in the OpenSSL cipher list format. (string value)
#ciphers = <None>

View File

@ -17,8 +17,10 @@ from oslo_config import cfg
from nimble.conf import api
from nimble.conf import database
from nimble.conf import default
CONF = cfg.CONF
api.register_opts(CONF)
database.register_opts(CONF)
default.register_opts(CONF)

62
nimble/conf/default.py Normal file
View File

@ -0,0 +1,62 @@
# Copyright 2016 Huawei Technologies Co.,LTD.
# 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.
import os
import socket
from oslo_config import cfg
from nimble.common.i18n import _
exc_log_opts = [
cfg.BoolOpt('fatal_exception_format_errors',
default=False,
help=_('Used if there is a formatting error when generating '
'an exception message (a programming error). If True, '
'raise an exception; if False, use the unformatted '
'message.')),
]
path_opts = [
cfg.StrOpt('pybasedir',
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
'../')),
sample_default='/usr/lib/python/site-packages/nimble/nimble',
help=_('Directory where the nimble python module is '
'installed.')),
cfg.StrOpt('bindir',
default='$pybasedir/bin',
help=_('Directory where nimble binaries are installed.')),
cfg.StrOpt('state_path',
default='$pybasedir',
help=_("Top-level directory for maintaining nimble's state.")),
]
service_opts = [
cfg.StrOpt('host',
default=socket.getfqdn(),
sample_default='localhost',
help=_('Name of this node. This can be an opaque identifier. '
'It is not necessarily a hostname, FQDN, or IP address. '
'However, the node name must be valid within '
'an AMQP key, and if using ZeroMQ, a valid '
'hostname, FQDN, or IP address.')),
]
def register_opts(conf):
conf.register_opts(exc_log_opts)
conf.register_opts(service_opts)
conf.register_opts(path_opts)

47
nimble/conf/opts.py Normal file
View File

@ -0,0 +1,47 @@
# 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 itertools
import nimble.conf.api
import nimble.conf.database
import nimble.conf.default
_default_opt_lists = [
nimble.conf.default.exc_log_opts,
nimble.conf.default.path_opts,
nimble.conf.default.service_opts,
]
_opts = [
('DEFAULT', itertools.chain(*_default_opt_lists)),
('api', nimble.conf.api.opts),
('database', nimble.conf.database.opts),
]
def list_opts():
"""Return a list of oslo.config options available in Nimble code.
The returned list includes all oslo.config options. Each element of
the list is a tuple. The first element is the name of the group, the
second element is the options.
The function is discoverable via the 'nimble' entry point under the
'oslo.config.opts' namespace.
The function is used by Oslo sample config file generator to discover the
options.
:returns: a list of (group, options) tuples
"""
return _opts

View File

@ -24,6 +24,9 @@ packages =
nimble
[entry_points]
oslo.config.opts =
nimble = nimble.conf.opts:list_opts
console_scripts =
nimble-api = nimble.cmd.api:main
nimble-dbsync = nimble.cmd.dbsync:main

0
tools/__init__.py Normal file
View File

View File

@ -0,0 +1,13 @@
[DEFAULT]
output_file = etc/nimble/nimble.conf.sample
wrap_width = 62
namespace = nimble
namespace = oslo.db
namespace = oslo.messaging
namespace = oslo.middleware.cors
namespace = oslo.concurrency
namespace = oslo.policy
namespace = oslo.log
namespace = oslo.service.service
namespace = oslo.service.periodic_task
namespace = oslo.service.sslutils

View File

@ -55,6 +55,12 @@ commands = oslo_debug_helper {posargs}
install_command = {[testenv:common-constraints]install_command}
commands = oslo_debug_helper {posargs}
[testenv:genconfig]
sitepackages = False
envdir = {toxworkdir}/venv
commands =
oslo-config-generator --config-file=tools/config/nimble-config-generator.conf
[flake8]
# E123, E125 skipped as they are invalid PEP-8.