Aodh 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: I781b095ed090c6de2550c3f9504e1d6b39a8af92
Related-Prod: PROD-21353
diff --git a/aodh/files/logging.conf b/aodh/files/logging.conf
deleted file mode 100644
index 440dd5e..0000000
--- a/aodh/files/logging.conf
+++ /dev/null
@@ -1,63 +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, aodh
-
-[handlers]
-keys = {{ log_handlers | join(", ") }}
-
-[formatters]
-keys = context, default{% if values.logging.log_handlers.get('fluentd', {}).get('enabled', False) %}, fluentd{% endif %}
-
-[logger_root]
-level = WARNING
-handlers = {{ log_handlers | join(", ") }}
-
-[logger_aodh]
-level = INFO
-handlers = {{ log_handlers | join(", ") }}
-qualname = aodh
-propagate = 0
-
-{%- 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/aodh/{{ 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/aodh/map.jinja b/aodh/map.jinja
index b1df315..121956a 100644
--- a/aodh/map.jinja
+++ b/aodh/map.jinja
@@ -19,6 +19,7 @@
           'policy_file': '/etc/aodh/policy.json'
         },
         'logging': {
+          'app_name': 'aodh',
           'log_appender': false,
           'log_handlers': {
             'watchedfile': {
@@ -39,6 +40,7 @@
           'policy_file': '/etc/aodh/policy.json'
         },
         'logging': {
+          'app_name': 'aodh',
           'log_appender': false,
           'log_handlers': {
             'watchedfile': {
diff --git a/aodh/server.sls b/aodh/server.sls
index fdf0186..1805af4 100644
--- a/aodh/server.sls
+++ b/aodh/server.sls
@@ -40,7 +40,7 @@
 aodh_general_logging_conf:
   file.managed:
     - name: /etc/aodh/logging.conf
-    - source: salt://aodh/files/logging.conf
+    - source: salt://oslo_templates/files/logging/_logging.conf
     - template: jinja
     - user: aodh
     - group: aodh
@@ -51,7 +51,7 @@
 {%- endif %}
     - defaults:
         service_name: aodh
-        values: {{ server }}
+        _data: {{ server.logging }}
     - watch_in:
       - service: aodh_server_services
 {%- if server.version not in ['mitaka'] %}
@@ -72,7 +72,7 @@
 {{ service_name }}_logging_conf:
   file.managed:
     - name: /etc/aodh/logging/logging-{{ service_name }}.conf
-    - source: salt://aodh/files/logging.conf
+    - source: salt://oslo_templates/files/logging/_logging.conf
     - template: jinja
     - user: aodh
     - group: aodh
@@ -84,7 +84,7 @@
     - makedirs: True
     - defaults:
         service_name: {{ service_name }}
-        values: {{ server }}
+        _data: {{ server.logging }}
     - watch_in:
       - service: aodh_server_services
 {% endfor %}