Remove unused notification method and class

The @notifications.internal decorator was recently removed in favor of inline
notifications. It was also the only method in keystone's notification framework
that used the notification.py:ManagerNotificationWrapper class, so that was
removed as well.

Change-Id: Ia5efbd9d9e3c1fad324dd7be84b2987048edb650
This commit is contained in:
Lance Bragstad 2016-03-04 23:46:58 +00:00
parent 8dfcac8ba6
commit 104616d5f2
1 changed files with 0 additions and 68 deletions

View File

@ -196,74 +196,6 @@ class Audit(object):
public)
class ManagerNotificationWrapper(object):
"""Send event notifications for ``Manager`` methods.
Sends a notification if the wrapped Manager method does not raise an
:class:`Exception` (such as :class:`keystone.exception.NotFound`).
:param operation: one of the values from ACTIONS
:param resource_type: type of resource being affected
:param public: If True (default), the event will be sent to the notifier
API. If False, the event will only be sent via
notify_event_callbacks to in process listeners
"""
def __init__(self, operation, resource_type, public=True,
resource_id_arg_index=1, result_id_arg_attr=None):
self.operation = operation
self.resource_type = resource_type
self.public = public
self.resource_id_arg_index = resource_id_arg_index
self.result_id_arg_attr = result_id_arg_attr
def __call__(self, f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
"""Send a notification if the wrapped callable is successful."""
try:
result = f(*args, **kwargs)
except Exception:
raise
else:
if self.result_id_arg_attr is not None:
resource_id = result[self.result_id_arg_attr]
else:
resource_id = args[self.resource_id_arg_index]
# NOTE(stevemar): the _send_notification function is
# overloaded, it's used to register callbacks and to actually
# send the notification externally. Thus, we should check
# the desired notification format in the function instead
# of before it.
_send_notification(
self.operation,
self.resource_type,
resource_id,
public=self.public)
# Only emit CADF notifications for public events
if CONF.notification_format == 'cadf' and self.public:
outcome = taxonomy.OUTCOME_SUCCESS
# NOTE(morganfainberg): The decorator form will always use
# a 'None' initiator, since we do not pass context around
# in a manner that allows the decorator to inspect context
# and extract the needed information.
initiator = None
_create_cadf_payload(self.operation, self.resource_type,
resource_id, outcome, initiator)
return result
return wrapper
def internal(*args, **kwargs):
"""Decorator to send notifications for internal notifications only."""
kwargs['public'] = False
return ManagerNotificationWrapper(ACTIONS.internal, *args, **kwargs)
def _get_callback_info(callback):
"""Return list containing callback's module and name.