use local config options if available in audit middleware

Some services such as Swift does not use Oslo (global) config. In that
case, make sure we can pass the options via local config instead. This is
consistent with how auth_token middleware handle global and local
config options.

Change-Id: Ica7f1a4de2676549b2b65cca0181f2a911156ee6
Closes-Bug: 1583702
This commit is contained in:
guang-yee 2016-05-26 15:30:43 -07:00 committed by Steve Martinelli
parent ed76943c92
commit 8859345f3b
2 changed files with 11 additions and 3 deletions

View File

@ -382,13 +382,13 @@ class AuditMiddleware(object):
if messaging:
transport = oslo_messaging.get_transport(
cfg.CONF,
url=cfg.CONF.audit_middleware_notifications.transport_url,
url=self._conf.get('transport_url'),
aliases=transport_aliases)
self._notifier = oslo_messaging.Notifier(
transport,
os.path.basename(sys.argv[0]),
driver=cfg.CONF.audit_middleware_notifications.driver,
topics=cfg.CONF.audit_middleware_notifications.topics)
driver=self._conf.get('driver'),
topics=self._conf.get('topics'))
def _emit_audit(self, context, event_type, payload):
"""Emit audit notification.

View File

@ -0,0 +1,8 @@
---
fixes:
- >
[`bug 1583702 <https://bugs.launchpad.net/keystonemiddleware/+bug/1583702>`_]
Some services such as Swift does not use Oslo (global) config. In that
case, the options are conveyed via local config. This patch utilized
an established pattern in auth_token middleware, which is to first
look for the given option in local config, then Oslo global config.