Skip to content

Commit

Permalink
Merge from oslo-incubator for notifier
Browse files Browse the repository at this point in the history
Goal: merge from oslo-incubator change  I282d4ae3311bc3fcda6be8e5a1fceecfc8ddb115

Done via:
python update.py --nodeps --base nova --dest-dir ../nova --modules notifier

Change-Id: I5ed80458f1073d6e5185e2769eed85a49dec5d10
  • Loading branch information
ajaeger committed Aug 12, 2013
1 parent 8fb450f commit 7b92cc7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
4 changes: 2 additions & 2 deletions etc/nova/nova.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@
# Options defined in nova.openstack.common.notifier.rpc_notifier
#

# AMQP topic used for openstack notifications (list value)
# AMQP topic used for OpenStack notifications (list value)
#notification_topics=notifications


Expand Down Expand Up @@ -2943,7 +2943,7 @@
# Options defined in nova.openstack.common.notifier.rpc_notifier2
#

# AMQP topic(s) used for openstack notifications (list value)
# AMQP topic(s) used for OpenStack notifications (list value)
#topics=notifications


Expand Down
29 changes: 8 additions & 21 deletions nova/openstack/common/notifier/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from oslo.config import cfg

from nova.openstack.common import context
from nova.openstack.common.gettextutils import _
from nova.openstack.common.gettextutils import _ # noqa
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
Expand Down Expand Up @@ -157,29 +157,16 @@ def _get_drivers():
if _drivers is None:
_drivers = {}
for notification_driver in CONF.notification_driver:
add_driver(notification_driver)

try:
driver = importutils.import_module(notification_driver)
_drivers[notification_driver] = driver
except ImportError:
LOG.exception(_("Failed to load notifier %s. "
"These notifications will not be sent.") %
notification_driver)
return _drivers.values()


def add_driver(notification_driver):
"""Add a notification driver at runtime."""
# Make sure the driver list is initialized.
_get_drivers()
if isinstance(notification_driver, basestring):
# Load and add
try:
driver = importutils.import_module(notification_driver)
_drivers[notification_driver] = driver
except ImportError:
LOG.exception(_("Failed to load notifier %s. "
"These notifications will not be sent.") %
notification_driver)
else:
# Driver is already loaded; just add the object.
_drivers[notification_driver] = notification_driver


def _reset_drivers():
"""Used by unit tests to reset the drivers."""
global _drivers
Expand Down
2 changes: 1 addition & 1 deletion nova/openstack/common/notifier/log_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def notify(_context, message):
"""Notifies the recipient of the desired event given the model.
Log notifications using openstack's default logging system.
Log notifications using OpenStack's default logging system.
"""

priority = message.get('priority',
Expand Down
4 changes: 2 additions & 2 deletions nova/openstack/common/notifier/rpc_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
from oslo.config import cfg

from nova.openstack.common import context as req_context
from nova.openstack.common.gettextutils import _
from nova.openstack.common.gettextutils import _ # noqa
from nova.openstack.common import log as logging
from nova.openstack.common import rpc

LOG = logging.getLogger(__name__)

notification_topic_opt = cfg.ListOpt(
'notification_topics', default=['notifications', ],
help='AMQP topic used for openstack notifications')
help='AMQP topic used for OpenStack notifications')

CONF = cfg.CONF
CONF.register_opt(notification_topic_opt)
Expand Down
4 changes: 2 additions & 2 deletions nova/openstack/common/notifier/rpc_notifier2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
from oslo.config import cfg

from nova.openstack.common import context as req_context
from nova.openstack.common.gettextutils import _
from nova.openstack.common.gettextutils import _ # noqa
from nova.openstack.common import log as logging
from nova.openstack.common import rpc

LOG = logging.getLogger(__name__)

notification_topic_opt = cfg.ListOpt(
'topics', default=['notifications', ],
help='AMQP topic(s) used for openstack notifications')
help='AMQP topic(s) used for OpenStack notifications')

opt_group = cfg.OptGroup(name='rpc_notifier2',
title='Options for rpc_notifier2')
Expand Down

0 comments on commit 7b92cc7

Please sign in to comment.