Neutron 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: I39ae8c816a019593a5b8e8add2d91f808f376a85
Related-Prod: PROD-21353
diff --git a/neutron/compute.sls b/neutron/compute.sls
index 2eefb6a..933680f 100644
--- a/neutron/compute.sls
+++ b/neutron/compute.sls
@@ -216,14 +216,14 @@
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/neutron/logging/logging-{{ service_name }}.conf
- - source: salt://neutron/files/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: True
- user: neutron
- group: neutron
- defaults:
service_name: {{ service_name }}
- values: {{ compute }}
+ _data: {{ compute.logging }}
- require:
- pkg: neutron_compute_packages
{% if compute.backend.sriov is defined %}
diff --git a/neutron/files/logging.conf b/neutron/files/logging.conf
deleted file mode 100644
index 6f5bcea..0000000
--- a/neutron/files/logging.conf
+++ /dev/null
@@ -1,86 +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, neutron, eventletwsgi
-
-[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_neutron]
-level = {{ values.logging.get('loggers', {}).get('neutron', {}).get('level', 'INFO') }}
-handlers = {{ log_handlers | join(", ") }}
-qualname = neutron
-
-[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
-
-[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', 'INFO') }}
-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("-", ".", 1) }}', 'localhost', 24224)
-formatter = fluentd
-{%- endif %}
-
-{%- if values.logging.log_handlers.watchedfile.enabled %}
-[handler_watchedfile]
-class = handlers.WatchedFileHandler
-args = ('/var/log/neutron/{{ 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/neutron/gateway.sls b/neutron/gateway.sls
index 66390d8..7dbea8f 100644
--- a/neutron/gateway.sls
+++ b/neutron/gateway.sls
@@ -94,14 +94,14 @@
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/neutron/logging/logging-{{ service_name }}.conf
- - source: salt://neutron/files/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: true
- user: neutron
- group: neutron
- defaults:
service_name: {{ service_name }}
- values: {{ gateway }}
+ _data: {{ gateway.logging }}
- require:
- pkg: neutron_gateway_packages
{%- if gateway.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}
diff --git a/neutron/map.jinja b/neutron/map.jinja
index e3b4cff..9b6b38a 100644
--- a/neutron/map.jinja
+++ b/neutron/map.jinja
@@ -19,6 +19,7 @@
'enabled': false
},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -39,6 +40,7 @@
'enabled': false
},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -66,6 +68,7 @@
'dpdk': false,
'notification': {},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -81,6 +84,7 @@
'dpdk': false,
'notification': {},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -109,6 +113,7 @@
'enabled': false
},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
@@ -133,6 +138,7 @@
'enabled': false
},
'logging': {
+ 'app_name': 'neutron',
'log_appender': false,
'log_handlers': {
'watchedfile': {
diff --git a/neutron/server.sls b/neutron/server.sls
index a432a46..e0c423f 100644
--- a/neutron/server.sls
+++ b/neutron/server.sls
@@ -168,12 +168,12 @@
{{ service_name }}_logging_conf:
file.managed:
- name: /etc/neutron/logging/logging-{{ service_name }}.conf
- - source: salt://neutron/files/logging.conf
+ - source: salt://oslo_templates/files/logging/_logging.conf
- template: jinja
- makedirs: True
- defaults:
service_name: {{ service_name }}
- values: {{ server }}
+ _data: {{ server.logging }}
- user: neutron
- group: neutron
- require: