diff options
author | Tim Simmons <tim.simmons@rackspace.com> | 2016-07-25 17:45:08 +0100 |
---|---|---|
committer | Tim Simmons <tim.simmons@rackspace.com> | 2017-01-19 16:10:15 +0000 |
commit | 93c0161242c1047e2fbe6dc241f1eaf3ffca874c (patch) | |
tree | a4c5510c73663208b6dd5843eb4af981398c0ba8 /designate/api | |
parent | 8966e7166b1a5e3dc0df5504de0ba002e2ddf8e5 (diff) | |
download | designate-93c0161242c1047e2fbe6dc241f1eaf3ffca874c.tar.gz |
Make notifications pluggable
- Defines a plugin interface for what's actually emitted as part
of designate "notifications".
- The default plugin emits the same thing as notifications did prior
to this patch.
- The "audit" notification plugin emits recordset data changes and
zone/recordset names, if they exist, the notifications with this
plugin look like http://paste.openstack.org/show/545210/
- Adds support for multiple notifications for a single change
- Also adds client IP to the context object, as it's a field that
may be of interest to some types of notifications
- Many tests
Change-Id: I01118fae8ce6e38ccc61b0ce763fd759affd9a86
Diffstat (limited to 'designate/api')
-rw-r--r-- | designate/api/middleware.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/designate/api/middleware.py b/designate/api/middleware.py index 49cfc024..0a941de8 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -107,6 +107,10 @@ class ContextMiddleware(base.Middleware): strutils.bool_from_string( request.headers.get('X-Designate-Edit-Managed-Records')) + def _extract_client_addr(self, ctxt, request): + if hasattr(request, 'client_addr'): + ctxt.client_addr = request.client_addr + def make_context(self, request, *args, **kwargs): req_id = request.environ.get(request_id.ENV_REQUEST_ID) kwargs.setdefault('request_id', req_id) @@ -118,6 +122,7 @@ class ContextMiddleware(base.Middleware): self._extract_all_projects(ctxt, request) self._extract_edit_managed_records(ctxt, request) self._extract_dns_hide_counts(ctxt, request) + self._extract_client_addr(ctxt, request) finally: request.environ['context'] = ctxt return ctxt |