From 7282251ee2e04213af6f9dbe04304468c6c51d64 Mon Sep 17 00:00:00 2001 From: Andrew Lazarev Date: Tue, 6 Jan 2015 12:14:44 -0800 Subject: [PATCH] Cleaned up config generator settings 1. Sahara opts are listed once 2. Oslo incubator opts are listed separately 3. Groups are referenced by variables Still things to improve: 1. opt-group mapping is listed twice now (in reg and in list) 2. registering spread across the project (should be in one place) 3. dependancies are not managed (it should be one place with CONF) Change-Id: I4b8edf26187b3c23d08f9efbee42086652efea5a Closes-Bug: #1407834 --- etc/sahara/sahara.conf.sample | 232 ++++++++++++---------- sahara/config.py | 41 ++-- setup.cfg | 6 +- tools/config/config-generator.sahara.conf | 6 +- 4 files changed, 147 insertions(+), 138 deletions(-) diff --git a/etc/sahara/sahara.conf.sample b/etc/sahara/sahara.conf.sample index f580ff6669..12a0411b8c 100644 --- a/etc/sahara/sahara.conf.sample +++ b/etc/sahara/sahara.conf.sample @@ -1,5 +1,103 @@ [DEFAULT] +# +# From log.config +# + +# Print debugging output (set logging level to DEBUG instead of +# default WARNING level). (boolean value) +#debug = false + +# Print more verbose output (set logging level to INFO instead of +# default WARNING level). (boolean value) +#verbose = false + +# +# From log.config +# + +# 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. +# (string value) +# Deprecated group/name - [DEFAULT]/log_config +#log_config_append = + +# DEPRECATED. A logging.Formatter log message format string which may +# use any of the available logging.LogRecord attributes. This option +# is deprecated. Please use logging_context_format_string and +# logging_default_format_string instead. (string value) +#log_format = + +# Format string for %%(asctime)s in log records. Default: %(default)s +# . (string value) +#log_date_format = %Y-%m-%d %H:%M:%S + +# (Optional) Name of log file to output to. If no default is set, +# logging will go to stdout. (string value) +# Deprecated group/name - [DEFAULT]/logfile +#log_file = + +# (Optional) The base directory used for relative --log-file paths. +# (string value) +# Deprecated group/name - [DEFAULT]/logdir +#log_dir = + +# Use syslog for logging. Existing syslog format is DEPRECATED during +# I, and will change in J to honor RFC5424. (boolean value) +#use_syslog = false + +# (Optional) Enables or disables syslog rfc5424 format for logging. If +# enabled, prefixes the MSG part of the syslog message with APP-NAME +# (RFC5424). The format without the APP-NAME is deprecated in I, and +# will be removed in J. (boolean value) +#use_syslog_rfc_format = false + +# Syslog facility to receive log lines. (string value) +#syslog_log_facility = LOG_USER + +# +# From log.config +# + +# Log output to standard error. (boolean value) +#use_stderr = true + +# +# From log.config +# + +# 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 without context. (string +# value) +#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s + +# Data to append to log format when level 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 TRACE %(name)s %(instance)s + +# List of logger=LEVEL pairs. (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,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN + +# Enables or disables publication of error events. (boolean value) +#publish_errors = false + +# Enables or disables fatal status of deprecations. (boolean value) +#fatal_deprecations = 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] " + # # From oslo.messaging # @@ -179,7 +277,33 @@ #control_exchange = openstack # -# From sahara +# From periodic.config +# + +# Some periodic tasks can be run in a separate process. Should we run +# them here? (boolean value) +#run_external_periodic_tasks = true + +# +# From policy.config +# + +# The JSON file that defines policies. (string value) +#policy_file = policy.json + +# Default rule. Enforced when a requested rule is not found. (string +# value) +#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. (multi +# valued) +#policy_dirs = policy.d + +# +# From sahara.config # # Hostname or IP address that will be used to listen on. (string @@ -233,106 +357,6 @@ # Driver to use for database access. (string value) #db_driver = sahara.db -# The JSON file that defines policies. (string value) -#policy_file = policy.json - -# Default rule. Enforced when a requested rule is not found. (string -# value) -#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. (multi -# valued) -#policy_dirs = policy.d - -# Print debugging output (set logging level to DEBUG instead of -# default WARNING level). (boolean value) -#debug = false - -# Print more verbose output (set logging level to INFO instead of -# default WARNING level). (boolean value) -#verbose = false - -# Log output to standard error. (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 without context. (string -# value) -#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s - -# Data to append to log format when level 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 TRACE %(name)s %(instance)s - -# List of logger=LEVEL pairs. (list value) -#default_log_levels = amqplib=WARN,qpid.messaging=INFO,stevedore=INFO,eventlet.wsgi.server=WARN,sqlalchemy=WARN,boto=WARN,suds=INFO,keystone=INFO,paramiko=WARN,requests=WARN,iso8601=WARN - -# Enables or disables publication of error events. (boolean value) -#publish_errors = false - -# Enables or disables fatal status of deprecations. (boolean value) -#fatal_deprecations = 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] " - -# 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. -# (string value) -# Deprecated group/name - [DEFAULT]/log_config -#log_config_append = - -# DEPRECATED. A logging.Formatter log message format string which may -# use any of the available logging.LogRecord attributes. This option -# is deprecated. Please use logging_context_format_string and -# logging_default_format_string instead. (string value) -#log_format = - -# Format string for %%(asctime)s in log records. Default: %(default)s -# . (string value) -#log_date_format = %Y-%m-%d %H:%M:%S - -# (Optional) Name of log file to output to. If no default is set, -# logging will go to stdout. (string value) -# Deprecated group/name - [DEFAULT]/logfile -#log_file = - -# (Optional) The base directory used for relative --log-file paths. -# (string value) -# Deprecated group/name - [DEFAULT]/logdir -#log_dir = - -# Use syslog for logging. Existing syslog format is DEPRECATED during -# I, and will change in J to honor RFC5424. (boolean value) -#use_syslog = false - -# (Optional) Enables or disables syslog rfc5424 format for logging. If -# enabled, prefixes the MSG part of the syslog message with APP-NAME -# (RFC5424). The format without the APP-NAME is deprecated in I, and -# will be removed in J. (boolean value) -#use_syslog_rfc_format = false - -# Syslog facility to receive log lines. (string value) -#syslog_log_facility = LOG_USER - -# Some periodic tasks can be run in a separate process. Should we run -# them here? (boolean value) -#run_external_periodic_tasks = true - # List of plugins to be loaded. Sahara preserves the order of the list # when returning it. (list value) #plugins = vanilla,hdp,spark @@ -388,10 +412,6 @@ # (string value) #proxy_command = -# -# From sahara_main -# - # Region name used to get services endpoints. (string value) #os_region_name = @@ -443,7 +463,7 @@ [conductor] # -# From sahara_main +# From sahara.config # # Perform sahara-conductor operations locally. (boolean value) diff --git a/sahara/config.py b/sahara/config.py index 79b2226b94..5f5f0c92c4 100644 --- a/sahara/config.py +++ b/sahara/config.py @@ -20,8 +20,6 @@ from oslo.config import cfg from sahara import exceptions as ex from sahara.i18n import _ from sahara.openstack.common import log -from sahara.openstack.common import periodic_task -from sahara.openstack.common import policy from sahara.plugins import base as plugins_base from sahara.topology import topology_helper from sahara.utils.notification import sender @@ -117,29 +115,6 @@ CONF.register_opts(db_opts) def list_opts(): - return [ - ('DEFAULT', - itertools.chain(cli_opts, - edp_opts, - networking_opts, - db_opts, - policy.policy_opts, - log.common_cli_opts, - log.generic_log_opts, - log.log_opts, - log.logging_cli_opts, - periodic_task.periodic_opts, - plugins_base.opts, - topology_helper.opts, - sender.notifier_opts, - cinder.opts, - keystone.opts, - remote.ssh_opts, - )), - ] - - -def main_opts(): # NOTE (vgridnev): we make these import here to avoid problems # with importing unregistered options in sahara code. # As example, importing 'node_domain' in @@ -153,13 +128,23 @@ def main_opts(): from sahara.utils import proxy return [ - ('DEFAULT', - itertools.chain(sahara_main.opts, + (None, + itertools.chain(cli_opts, + edp_opts, + networking_opts, + db_opts, + plugins_base.opts, + topology_helper.opts, + sender.notifier_opts, + cinder.opts, + keystone.opts, + remote.ssh_opts, + sahara_main.opts, job_utils.opts, periodic.periodic_opts, volumes.opts, proxy.opts)), - ('conductor', + (api.conductor_group.name, itertools.chain(api.conductor_opts)), ] diff --git a/setup.cfg b/setup.cfg index 9b75eebe87..8fcc7b4991 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,8 +56,10 @@ sahara.run.mode = distributed = sahara.service.ops:RemoteOps oslo.config.opts = - sahara = sahara.config:list_opts - sahara_main = sahara.config:main_opts + sahara.config = sahara.config:list_opts + log.config = sahara.openstack.common.log:list_opts + periodic.config = sahara.openstack.common.periodic_task:list_opts + policy.config = sahara.openstack.common.policy:list_opts [build_sphinx] all_files = 1 diff --git a/tools/config/config-generator.sahara.conf b/tools/config/config-generator.sahara.conf index bb92498ec0..7b89f3acc3 100644 --- a/tools/config/config-generator.sahara.conf +++ b/tools/config/config-generator.sahara.conf @@ -1,7 +1,9 @@ [DEFAULT] -namespace = sahara +namespace = sahara.config namespace = oslo.db namespace = oslo.messaging namespace = oslo.concurrency namespace = keystonemiddleware.auth_token -namespace = sahara_main +namespace = log.config +namespace = periodic.config +namespace = policy.config