Merge "Catch loading failures if transport_url is not set" into milestone-proposed
This commit is contained in:
commit
438ec09c5f
@ -77,10 +77,20 @@ class Notifier(object):
|
||||
|
||||
publisher_id = CONF.default_publisher_id
|
||||
|
||||
# NOTE(flaper87): Assume the user has configured
|
||||
# the transport url.
|
||||
self._transport = messaging.get_transport(CONF,
|
||||
aliases=_ALIASES)
|
||||
try:
|
||||
# NOTE(flaper87): Assume the user has configured
|
||||
# the transport url.
|
||||
self._transport = messaging.get_transport(CONF,
|
||||
aliases=_ALIASES)
|
||||
except messaging.DriverLoadFailure:
|
||||
# NOTE(flaper87): Catch driver load failures and re-raise
|
||||
# them *just* if the `transport_url` option was set. This
|
||||
# step is intended to keep backwards compatibility and avoid
|
||||
# weird behaviors (like exceptions on missing dependencies)
|
||||
# when the old notifier options are used.
|
||||
if CONF.transport_url is not None:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_('Error loading the notifier'))
|
||||
|
||||
# NOTE(flaper87): This needs to be checked
|
||||
# here because the `get_transport` call
|
||||
|
@ -103,11 +103,12 @@ class TestNotifier(utils.BaseTestCase):
|
||||
self.assertEqual(str(nfier._transport._driver._url),
|
||||
'qpid:///')
|
||||
|
||||
def test_custom_strategy(self):
|
||||
st = "glance.notifier.notify_noop.NoopStrategy"
|
||||
self.config(notifier_strategy=st)
|
||||
#NOTE(bcwaldon): the fact that Notifier is instantiated means we're ok
|
||||
notifier.Notifier()
|
||||
def test_notifier_strategy(self):
|
||||
self.config(notifier_strategy='qpid')
|
||||
nfier = notifier.Notifier()
|
||||
self.assertIsNotNone(nfier._transport)
|
||||
self.assertEqual(str(nfier._transport._driver._url),
|
||||
'qpid:///')
|
||||
|
||||
def test_transport_url(self):
|
||||
transport_url = "qpid://superhost:5672/"
|
||||
|
Loading…
Reference in New Issue
Block a user