diff --git a/glance/notifier.py b/glance/notifier.py index a482e4105b..e9659893e3 100644 --- a/glance/notifier.py +++ b/glance/notifier.py @@ -64,16 +64,20 @@ class Notifier(object): def __init__(self, strategy=None): + _driver = None + _strategy = strategy + if CONF.notifier_strategy != 'default': msg = _("notifier_strategy was deprecated in " "favor of `notification_driver`") warnings.warn(msg, DeprecationWarning) - # NOTE(flaper87): Use this to keep backwards - # compatibility. We'll try to get an oslo.messaging - # driver from the specified strategy. - _strategy = strategy or CONF.notifier_strategy - _driver = _STRATEGY_ALIASES.get(_strategy) + # NOTE(flaper87): Use this to keep backwards + # compatibility. We'll try to get an oslo.messaging + # driver from the specified strategy. + _strategy = strategy or CONF.notifier_strategy + _driver = _STRATEGY_ALIASES.get(_strategy) + publisher_id = CONF.default_publisher_id # NOTE(flaper87): Assume the user has configured diff --git a/glance/tests/unit/test_notifier.py b/glance/tests/unit/test_notifier.py index 69eb036696..b6e113b7d1 100644 --- a/glance/tests/unit/test_notifier.py +++ b/glance/tests/unit/test_notifier.py @@ -114,6 +114,19 @@ class TestNotifier(utils.BaseTestCase): self.assertEqual(str(notify._transport._driver._url), transport_url) + def test_notification_driver_option(self): + self.config(rpc_backend='qpid') + self.config(notification_driver='messaging') + self.config(notifier_strategy='rabbit') + notify = notifier.Notifier() + self.assertEqual(str(notify._transport._driver._url), + 'rabbit:///') + + self.config(notifier_strategy='default') + notify = notifier.Notifier() + self.assertEqual(str(notify._transport._driver._url), + 'qpid:///') + class TestImageNotifications(utils.BaseTestCase): """Test Image Notifications work"""