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:
@@ -17,7 +17,9 @@ import uuid
|
|||||||
|
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
from nova import log as logging
|
||||||
|
|
||||||
|
LOG = logging.getLogger('nova.exception')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
@@ -37,6 +39,12 @@ class BadPriorityException(Exception):
|
|||||||
pass
|
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):
|
def notify(publisher_id, event_type, priority, payload):
|
||||||
"""
|
"""
|
||||||
Sends a notification using the specified driver
|
Sends a notification using the specified driver
|
||||||
@@ -79,4 +87,8 @@ def notify(publisher_id, event_type, priority, payload):
|
|||||||
priority=priority,
|
priority=priority,
|
||||||
payload=payload,
|
payload=payload,
|
||||||
timestamp=str(utils.utcnow()))
|
timestamp=str(utils.utcnow()))
|
||||||
driver.notify(msg)
|
try:
|
||||||
|
driver.notify(msg)
|
||||||
|
except Exception, e:
|
||||||
|
LOG.exception(_("Problem '%(e)s' attempting to "
|
||||||
|
"send to notification system." % locals()))
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ class AdapterConsumer(Consumer):
|
|||||||
return
|
return
|
||||||
self.pool.spawn_n(self._process_data, msg_id, ctxt, method, args)
|
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):
|
def _process_data(self, msg_id, ctxt, method, args):
|
||||||
"""Thread that maigcally looks for a method on the proxy
|
"""Thread that maigcally looks for a method on the proxy
|
||||||
object and calls it.
|
object and calls it.
|
||||||
|
|||||||
Reference in New Issue
Block a user