Add priority based queues to notifications.

Remove duplicate json encoding in notifier (rpc.cast does encoding... ) 
make no_op_notifier  match rabbit one for signature on notify()
This commit is contained in:
Monsyne Dragon
2011-05-10 23:29:16 +00:00
parent 60b6e8034c
commit f73c82fe36
4 changed files with 30 additions and 13 deletions

View File

@@ -14,14 +14,13 @@
# under the License.
import datetime
import json
from nova import flags
from nova import utils
FLAGS = flags.FLAGS
flags.DEFINE_string('default_notification_level', 'info',
flags.DEFINE_string('default_notification_level', 'INFO',
'Default notification level for outgoing notifications')
WARN = 'WARN'
@@ -69,4 +68,4 @@ def notify(event_name, publisher_id, event_type, priority, payload):
priority=priority,
payload=payload,
time=str(datetime.datetime.utcnow()))
driver.notify(json.dumps(message))
driver.notify(message)

View File

@@ -14,6 +14,6 @@
# under the License.
class NoopNotifier(object):
def notify(self, event_name, model):
def notify(self, payload):
"""Notifies the recipient of the desired event given the model"""
pass

View File

@@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
import nova.context
@@ -28,10 +27,12 @@ flags.DEFINE_string('notification_topic', 'notifications',
class RabbitNotifier(object):
"""Sends notifications to a specific RabbitMQ server and topic"""
pass
def notify(self, payload):
"""Sends a notification to the RabbitMQ"""
context = nova.context.get_admin_context()
topic = FLAGS.notification_topic
priority = payload.get('priority',
FLAGS.default_notification_level)
priority = priority.lower()
topic = '%s.%s' % (FLAGS.notification_topic, priority)
rpc.cast(context, topic, payload)