Manila add ability to use global logging.conf
Add ability to use global logging.conf template which can be
used in all openstack components which support oslo.log
Change-Id: Ib425a68c8d4d88c38db6fccf69a9852d05f03800
Related-Prod: PROD-21353
diff --git a/manila/_logging.sls b/manila/_logging.sls
index 700f008..0e4cade 100644
--- a/manila/_logging.sls
+++ b/manila/_logging.sls
@@ -7,14 +7,14 @@
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/manila/logging/logging-{{ service_name }}.conf
- - source: salt://manila/files/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: True
- user: manila
- group: manila
- defaults:
service_name: {{ service_name }}
- values: {{ config }}
+ _data: {{ config.logging }}
- require:
- pkg: {{ service_name }}_pkg
{%- if config.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
diff --git a/manila/api.sls b/manila/api.sls
index ca82717..680af96 100644
--- a/manila/api.sls
+++ b/manila/api.sls
@@ -1,4 +1,4 @@
-{%- from "manila/map.jinja" import api with context %}
+{%- from "manila/map.jinja" import api, cfg with context %}
{%- if api.enabled %}
include:
- apache
@@ -8,7 +8,39 @@
pkg.installed:
- names: {{ api.pkgs }}
-manila_install_database:
+{% if not api.get('logging', {}).get('log_appender', False) %}
+{%- do api.update({'logging': cfg.logging})%}
+{% endif %}
+
+{% if api.logging.log_appender == True %}
+
+{%- if api.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
+manila_api_fluentd_logger_package:
+ pkg.installed:
+ - name: python-fluent-logger
+{%- endif %}
+
+manila_api_general_conf:
+ file.managed:
+ - name: /etc/manila/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
+ - template: jinja
+ - makedirs: True
+ - user: manila
+ - group: manila
+ - defaults:
+ service_name: manila-api
+ _data: {{ api.logging }}
+ - require:
+ - pkg: manila_api_packages
+{%- if api.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
+ - pkg: manila_api_fluentd_logger_package
+{%- endif %}
+ - watch_in:
+ - service: {{ api.service }}
+{% endif %}
+
+manila_install_apibase:
cmd.run:
- names:
- manila-manage --config-file /etc/manila/manila.conf db sync
diff --git a/manila/files/logging.conf b/manila/files/logging.conf
deleted file mode 100644
index 7c43591..0000000
--- a/manila/files/logging.conf
+++ /dev/null
@@ -1,95 +0,0 @@
-{%- set log_handlers = [] -%}
-{%- for log_handler_name, log_handler_attrs in values.logging.log_handlers.items() %}
- {%- if log_handler_attrs.get('enabled', False) %}
- {%- do log_handlers.append(log_handler_name) -%}
- {%- endif %}
-{%- endfor %}
-[loggers]
-keys = root, manila
-
-[handlers]
-keys = {{ log_handlers | join(", ") }}
-
-[formatters]
-keys = context, default{% if values.logging.log_handlers.get('fluentd',{}).get('enabled', False) %}, fluentd{% endif %}
-
-[logger_root]
-level = {{ values.logging.get('loggers', {}).get('root', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-
-[logger_amqp]
-level = {{ values.logging.get('loggers', {}).get('amqp', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = amqp
-
-[logger_manila]
-level = {{ values.logging.get('loggers', {}).get('manila', {}).get('level', 'INFO') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = manila
-propagate = 0
-
-[logger_amqplib]
-level = {{ values.logging.get('loggers', {}).get('amqplib', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = amqplib
-
-[logger_sqlalchemy]
-level = {{ values.logging.get('loggers', {}).get('sqlalchemy', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = sqlalchemy
-# "level = INFO" logs SQL queries.
-# "level = DEBUG" logs SQL queries and results.
-# "level = WARNING" logs neither. (Recommended for production systems.)
-
-[logger_boto]
-level = {{ values.logging.get('loggers', {}).get('boto', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = boto
-
-[logger_suds]
-level = {{ values.logging.get('loggers', {}).get('suds', {}).get('level', 'INFO') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = suds
-
-[logger_eventletwsgi]
-level = {{ values.logging.get('loggers', {}).get('eventletwsgi', {}).get('level', 'WARNING') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = eventlet.wsgi.server
-
-{%- if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
-[handler_fluentd]
-class = fluent.handler.FluentHandler
-args = ('openstack.{{ service_name | replace("-", ".") }}', 'localhost', 24224)
-formatter = fluentd
-{%- endif %}
-
-{%- if values.logging.log_handlers.watchedfile.enabled %}
-[handler_watchedfile]
-class = handlers.WatchedFileHandler
-args = ('/var/log/manila/{{ service_name }}.log',)
-formatter = context
-{%- endif %}
-
-{% if values.logging.log_handlers.get('ossyslog', {}).get('enabled', False) -%}
-{%- set ossyslog_args = values.logging.log_handlers.ossyslog.get('args', {}) -%}
-[handler_ossyslog]
-class = oslo_log.handlers.OSSysLogHandler
-# the OSSysLogHandler uses 'syslog' lib, where the LOG_* facilities are already *8
-# but in the context where the args are evaluated we have access only to Python's
-# handlers.SysLogHandler.LOG_* constants that _ARE_NOT_ multiplied by 8.
-# To not have a completely magic single int in the rendered template,
-# we multiply it here.
-args = ( 8 * handlers.SysLogHandler.{{ ossyslog_args.get('facility', 'LOG_USER') }}, )
-formatter = context
-{%- endif %}
-
-[formatter_context]
-class = oslo_log.formatters.ContextFormatter
-
-[formatter_default]
-format = %(message)s
-
-{%- if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
-[formatter_fluentd]
-class = oslo_log.formatters.FluentFormatter
-{%- endif %}
diff --git a/manila/map.jinja b/manila/map.jinja
index 4b7aa93..606a4ca 100644
--- a/manila/map.jinja
+++ b/manila/map.jinja
@@ -7,6 +7,7 @@
{% set cfg = salt['grains.filter_by']({
'Debian': {
'logging': {
+ 'app_name': 'manila',
'log_appender': false,
'log_handlers': {
'watchedfile': {