summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-07-01 07:31:17 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-07-01 07:31:17 -0700
commite789dd29c48ee8ad2b10eeb9ff24725f0e696bed (patch)
treeb2afd77ae9ae7a1245a41e73be3348e5e0e2e2a9
parentfbe296a7ab3bf1b9ee2bf765d13b5675ff4d6295 (diff)
downloadnova-e789dd29c48ee8ad2b10eeb9ff24725f0e696bed.tar.gz
nova-e789dd29c48ee8ad2b10eeb9ff24725f0e696bed.tar.xz
nova-e789dd29c48ee8ad2b10eeb9ff24725f0e696bed.zip
review fixes
-rw-r--r--nova/exception.py4
-rw-r--r--nova/notifier/api.py14
-rw-r--r--nova/tests/test_exception.py7
3 files changed, 13 insertions, 12 deletions
diff --git a/nova/exception.py b/nova/exception.py
index ea590199c..6e277b68d 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -113,8 +113,8 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None,
# propagated.
temp_type = f.__name__
- notifier.safe_notify(publisher_id, temp_type, temp_level,
- payload)
+ notifier.notify(publisher_id, temp_type, temp_level,
+ payload)
if not isinstance(e, Error):
#exc_type, exc_value, exc_traceback = sys.exc_info()
diff --git a/nova/notifier/api.py b/nova/notifier/api.py
index d388eda96..98969fd3e 100644
--- a/nova/notifier/api.py
+++ b/nova/notifier/api.py
@@ -45,14 +45,6 @@ def publisher_id(service, host=None):
return "%s.%s" % (service, host)
-def safe_notify(publisher_id, event_type, priority, payload):
- try:
- notify(publisher_id, event_type, notification_level, payload)
- except Exception, e:
- LOG.exception(_("Problem '%(e)s' attempting to "
- "send to notification system." % locals()))
-
-
def notify(publisher_id, event_type, priority, payload):
"""
Sends a notification using the specified driver
@@ -95,4 +87,8 @@ def notify(publisher_id, event_type, priority, payload):
priority=priority,
payload=payload,
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()))
diff --git a/nova/tests/test_exception.py b/nova/tests/test_exception.py
index 16e273f89..692b714e5 100644
--- a/nova/tests/test_exception.py
+++ b/nova/tests/test_exception.py
@@ -64,11 +64,16 @@ def bad_function_exception():
class WrapExceptionTestCase(test.TestCase):
- def test_wrap_exception(self):
+ def test_wrap_exception_good_return(self):
wrapped = exception.wrap_exception()
self.assertEquals(99, wrapped(good_function)())
+
+ def test_wrap_exception_throws_error(self):
+ wrapped = exception.wrap_exception()
self.assertRaises(exception.Error, wrapped(bad_function_error))
+ def test_wrap_exception_throws_exception(self):
+ wrapped = exception.wrap_exception()
# Note that Exception is converted to Error ...
self.assertRaises(exception.Error, wrapped(bad_function_exception))