From 46ab81b8b4342d73732149880bbe27d39e96b9ee Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Mon, 9 Feb 2015 17:44:50 +0300 Subject: [PATCH] Add sample conf file and generator tox target --- config-generator.conf | 5 ++ etc/shaker.conf | 129 ++++++++++++++++++++++++++++++++++++++++ setup.cfg | 4 ++ shaker/agent/agent.py | 2 + shaker/engine/config.py | 23 ++++--- shaker/engine/server.py | 6 +- tox.ini | 4 ++ 7 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 config-generator.conf create mode 100644 etc/shaker.conf diff --git a/config-generator.conf b/config-generator.conf new file mode 100644 index 0000000..abede34 --- /dev/null +++ b/config-generator.conf @@ -0,0 +1,5 @@ +[DEFAULT] +output_file = etc/shaker.conf +wrap_width = 79 +namespace = shaker.engine.config +namespace = shaker.openstack.common.log diff --git a/etc/shaker.conf b/etc/shaker.conf new file mode 100644 index 0000000..81f125e --- /dev/null +++ b/etc/shaker.conf @@ -0,0 +1,129 @@ +[DEFAULT] + +# +# From shaker.engine.config +# + +# Address for server connections (host:port) (string value) +#server_endpoint = + +# +# From shaker.engine.config +# + +# Authentication URL, defaults to env[OS_AUTH_URL]. (string value) +#os_auth_url = http://172.18.161.230:5000/v2.0 + +# Authentication tenant name, defaults to env[OS_TENANT_NAME]. (string value) +#os_tenant_name = admin + +# Authentication username, defaults to env[OS_USERNAME]. (string value) +#os_username = admin + +# Authentication password, defaults to env[OS_PASSWORD]. (string value) +#os_password = admin + +# Scenario file name (string value) +#scenario = + +# +# From shaker.engine.config +# + +# The id of instance where agent is running (string value) +#instance_id = + +# +# From shaker.openstack.common.log +# + +# 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 shaker.openstack.common.log +# + +# 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 shaker.openstack.common.log +# + +# Log output to standard error. (boolean value) +#use_stderr = true + +# +# From shaker.openstack.common.log +# + +# 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] " diff --git a/setup.cfg b/setup.cfg index c08d3d7..476ac8d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,3 +26,7 @@ packages = console_scripts = shaker = shaker.engine.server:main shaker-agent = shaker.agent.agent:main + +oslo.config.opts = + shaker.openstack.common.log = shaker.openstack.common.log:list_opts + shaker.engine.config = shaker.engine.config:list_opts diff --git a/shaker/agent/agent.py b/shaker/agent/agent.py index b25adc8..48dba3f 100644 --- a/shaker/agent/agent.py +++ b/shaker/agent/agent.py @@ -64,7 +64,9 @@ def send_reply(socket, instance_id, result): def main(): # init conf and logging conf = cfg.CONF + conf.register_cli_opts(config.COMMON_OPTS) conf.register_cli_opts(config.AGENT_OPTS) + conf.register_opts(config.COMMON_OPTS) conf.register_opts(config.AGENT_OPTS) try: diff --git a/shaker/engine/config.py b/shaker/engine/config.py index 5fdc8de..a23fa3d 100644 --- a/shaker/engine/config.py +++ b/shaker/engine/config.py @@ -13,11 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +import copy + from oslo.config import cfg from shaker.engine import utils -OPTS = [ +COMMON_OPTS = [ + cfg.StrOpt('server-endpoint', + required=True, + help='Address for server connections (host:port)'), +] + +SERVER_OPTS = [ cfg.StrOpt('os-auth-url', metavar='', default=utils.env('OS_AUTH_URL'), help='Authentication URL, defaults to env[OS_AUTH_URL].'), @@ -35,16 +43,15 @@ OPTS = [ cfg.StrOpt('scenario', required=True, help='Scenario file name'), - - cfg.StrOpt('server-endpoint', - required=True, - help='Address for server connections (host:port)'), ] AGENT_OPTS = [ - cfg.StrOpt('server-endpoint', - required=True, - help='Address for server connections (host:port)'), cfg.StrOpt('instance-id', help='The id of instance where agent is running'), ] + + +def list_opts(): + yield (None, copy.deepcopy(COMMON_OPTS)) + yield (None, copy.deepcopy(SERVER_OPTS)) + yield (None, copy.deepcopy(AGENT_OPTS)) diff --git a/shaker/engine/server.py b/shaker/engine/server.py index bc3076b..f3715f3 100644 --- a/shaker/engine/server.py +++ b/shaker/engine/server.py @@ -183,8 +183,10 @@ def execute(execution, brigades): def main(): # init conf and logging conf = cfg.CONF - conf.register_cli_opts(config.OPTS) - conf.register_opts(config.OPTS) + conf.register_cli_opts(config.COMMON_OPTS) + conf.register_cli_opts(config.SERVER_OPTS) + conf.register_opts(config.COMMON_OPTS) + conf.register_opts(config.SERVER_OPTS) try: conf(project='shaker') diff --git a/tox.ini b/tox.ini index 9da4ed4..9a2a545 100644 --- a/tox.ini +++ b/tox.ini @@ -30,6 +30,10 @@ commands = bash -c "find {toxinidir} -type f -not -wholename \*.tox/\* -and \( - [testenv:cover] commands = python setup.py testr --coverage --testr-args='{posargs}' +[testenv:genconfig] +commands = + oslo-config-generator --config-file=config-generator.conf + [tox:jenkins] downloadcache = ~/cache/pip