Extends the exception.wrap_exception decorator to optionally send an update to the notification system in the event of a failure.

This commit is contained in:
Sandy Walsh
2011-07-13 18:36:47 +00:00
committed by Tarmac
2 changed files with 14 additions and 2 deletions

View File

@@ -17,7 +17,9 @@ import uuid
from nova import flags
from nova import utils
from nova import log as logging
LOG = logging.getLogger('nova.exception')
FLAGS = flags.FLAGS
@@ -37,6 +39,12 @@ class BadPriorityException(Exception):
pass
def publisher_id(service, host=None):
if not host:
host = FLAGS.host
return "%s.%s" % (service, host)
def notify(publisher_id, event_type, priority, payload):
"""
Sends a notification using the specified driver
@@ -79,4 +87,8 @@ def notify(publisher_id, event_type, priority, payload):
priority=priority,
payload=payload,
timestamp=str(utils.utcnow()))
try:
driver.notify(msg)
except Exception, e:
LOG.exception(_("Problem '%(e)s' attempting to "
"send to notification system." % locals()))

View File

@@ -219,7 +219,7 @@ class AdapterConsumer(Consumer):
return
self.pool.spawn_n(self._process_data, msg_id, ctxt, method, args)
@exception.wrap_exception
@exception.wrap_exception()
def _process_data(self, msg_id, ctxt, method, args):
"""Thread that maigcally looks for a method on the proxy
object and calls it.