diff options
author | Dan Prince <dprince@redhat.com> | 2012-11-05 14:12:45 -0500 |
---|---|---|
committer | Dan Prince <dprince@redhat.com> | 2012-11-05 14:24:55 -0500 |
commit | 5b86a006d823953daec121a3b6b4897d803e7e01 (patch) | |
tree | 3913bdaac64ce293741cc6631997e57da6156197 | |
parent | d41e45b9946fc0dd4d1a2c90a848d1f92d58fc11 (diff) | |
download | oslo-5b86a006d823953daec121a3b6b4897d803e7e01.tar.gz oslo-5b86a006d823953daec121a3b6b4897d803e7e01.tar.xz oslo-5b86a006d823953daec121a3b6b4897d803e7e01.zip |
Rename rabbit_notifier to rpc_notifier.
The previous rabbit_notifier module is generic and can be used
for all RPC notifications.
This commit moves the rabbit_notifier module to rpc_notifier and
adds a new deprecated rabbit_notifier module which can be used for Grizzly
so that users can have a chance to easily upgrade this config setting.
Once this lands here I'd like to do the same in Quantum.
Change-Id: I95073b1a8e06673d8e7363a4b37c050adbad97c5
-rw-r--r-- | openstack/common/notifier/rabbit_notifier.py | 31 | ||||
-rw-r--r-- | openstack/common/notifier/rpc_notifier.py | 46 |
2 files changed, 53 insertions, 24 deletions
diff --git a/openstack/common/notifier/rabbit_notifier.py b/openstack/common/notifier/rabbit_notifier.py index 3a2ffee..56a37e4 100644 --- a/openstack/common/notifier/rabbit_notifier.py +++ b/openstack/common/notifier/rabbit_notifier.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2012 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -14,33 +14,16 @@ # under the License. -from openstack.common import cfg -from openstack.common import context as req_context from openstack.common.gettextutils import _ from openstack.common import log as logging -from openstack.common import rpc +from openstack.common.notifier import rpc_notifier LOG = logging.getLogger(__name__) -notification_topic_opt = cfg.ListOpt( - 'notification_topics', default=['notifications', ], - help='AMQP topic used for openstack notifications') - -CONF = cfg.CONF -CONF.register_opt(notification_topic_opt) - def notify(context, message): - """Sends a notification to the RabbitMQ""" - if not context: - context = req_context.get_admin_context() - priority = message.get('priority', - CONF.default_notification_level) - priority = priority.lower() - for topic in CONF.notification_topics: - topic = '%s.%s' % (topic, priority) - try: - rpc.notify(context, topic, message) - except Exception, e: - LOG.exception(_("Could not send notification to %(topic)s. " - "Payload=%(message)s"), locals()) + """Deprecated in Grizzly. Please use rpc_notifier instead.""" + + LOG.deprecated(_("The rabbit_notifier is now deprecated." + " Please use rpc_notifier instead.")) + rpc_notifier.notify(context, message) diff --git a/openstack/common/notifier/rpc_notifier.py b/openstack/common/notifier/rpc_notifier.py new file mode 100644 index 0000000..604af86 --- /dev/null +++ b/openstack/common/notifier/rpc_notifier.py @@ -0,0 +1,46 @@ +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from openstack.common import cfg +from openstack.common import context as req_context +from openstack.common.gettextutils import _ +from openstack.common import log as logging +from openstack.common import rpc + +LOG = logging.getLogger(__name__) + +notification_topic_opt = cfg.ListOpt( + 'notification_topics', default=['notifications', ], + help='AMQP topic used for openstack notifications') + +CONF = cfg.CONF +CONF.register_opt(notification_topic_opt) + + +def notify(context, message): + """Sends a notification via RPC""" + if not context: + context = req_context.get_admin_context() + priority = message.get('priority', + CONF.default_notification_level) + priority = priority.lower() + for topic in CONF.notification_topics: + topic = '%s.%s' % (topic, priority) + try: + rpc.notify(context, topic, message) + except Exception, e: + LOG.exception(_("Could not send notification to %(topic)s. " + "Payload=%(message)s"), locals()) |