From 5a0c2e9c07b71a75265481123198979ab819a994 Mon Sep 17 00:00:00 2001 From: Saad Zaher Date: Mon, 22 Feb 2016 15:24:08 +0000 Subject: [PATCH] Add oslo.config entry point for Freezer-scheduler Allows freezer-scheduler to generate sample config files for the ease of use. To generate a config file use the following command: oslo-config-generator --config-file config-generator/scheduler.conf it will generate a sample config file in freezer/etc Change-Id: Ib24454708b19a1a2ea3e374cbb3b374b1c66e685 Closes-Bug: #1548346 --- config-generator/scheduler.conf | 6 ++ etc/scheduler.conf.sample | 138 ++++++++++++++++++++++++++++++++ freezer/scheduler/arguments.py | 9 ++- setup.cfg | 1 + 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 config-generator/scheduler.conf create mode 100644 etc/scheduler.conf.sample diff --git a/config-generator/scheduler.conf b/config-generator/scheduler.conf new file mode 100644 index 00000000..32ee9ef1 --- /dev/null +++ b/config-generator/scheduler.conf @@ -0,0 +1,6 @@ +[DEFAULT] +output_file = etc/scheduler.conf.sample +wrap_width = 79 +namespace = scheduler +namespace = oslo.log + diff --git a/etc/scheduler.conf.sample b/etc/scheduler.conf.sample new file mode 100644 index 00000000..7deb1389 --- /dev/null +++ b/etc/scheduler.conf.sample @@ -0,0 +1,138 @@ +[DEFAULT] + +# +# From oslo.log +# + +# If set to true, the logging level will be set to DEBUG instead of the default +# INFO level. (boolean value) +#debug = false + +# 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 all logging configuration is defined in the +# configuration file and other logging configuration options are ignored (for +# example, log_format). (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. This option is ignored if log_config_append is set. (string value) +#log_format = + +# 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 = + +# (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 = + +# 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 + +# Enables or disables syslog rfc5424 format for logging. If enabled, prefixes +# the MSG part of the syslog message with APP-NAME (RFC5424). This option is +# ignored if log_config_append is set. (boolean value) +# This option is deprecated for removal. +# Its value may be silently ignored in the future. +# Reason: The format without the APP-NAME is deprecated in Kilo, and will be +# removed in Mitaka, along with this option. +#use_syslog_rfc_format = true + +# 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 scheduler +# + +# Specifies the client_id used when contacting the service. +# If not specified it will be automatically created +# using the tenant-id and the machine hostname. (string value) +#client_id = + +# Prevents the scheduler from using the api service (boolean value) +#no_api = false + +# Used to store/retrieve files on local storage, including those exchanged with +# the api service.Default value is /etc/freezer/scheduler/conf.d (Env: +# FREEZER_SCHEDULER_CONF_D) (string value) +#jobs_dir = /etc/freezer/scheduler/conf.d + +# Specifies the api-polling interval in seconds. Defaults to 60 seconds +# (integer value) +#interval = 60 + +# Prevents the scheduler from running in daemon mode (boolean value) +#no_daemon = false + +# Initialize freezer scheduler with insecure mode (boolean value) +#insecure = false diff --git a/freezer/scheduler/arguments.py b/freezer/scheduler/arguments.py index 563bf571..08f2cd06 100644 --- a/freezer/scheduler/arguments.py +++ b/freezer/scheduler/arguments.py @@ -100,7 +100,7 @@ def getCommonOpts(): def parse_args(choices): - default_conf = cfg.find_config_files('freezer', 'freezer-scheduler', + default_conf = cfg.find_config_files('freezer', 'scheduler', '.conf') CONF.register_cli_opts(api_client.build_os_options()) CONF.register_cli_opts(getCommonOpts()) @@ -135,3 +135,10 @@ def setup_logging(): '%(message)s') log.set_defaults(_DEFAULT_LOGGING_CONTEXT_FORMAT, _DEFAULT_LOG_LEVELS) log.setup(CONF, 'freezer-scheduler', version=FREEZER_VERSION) + + +def list_opts(): + _opt = { + None: getCommonOpts() + } + return _opt.items() diff --git a/setup.cfg b/setup.cfg index dcde2a7d..b7b268a1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,6 +55,7 @@ data_files = [entry_points] oslo.config.opts = freezer = freezer.common.config:list_opts + scheduler = freezer.scheduler.arguments:list_opts console_scripts = freezer-scheduler = freezer.scheduler.freezer_scheduler:main freezerc = freezer.main:main