Notifications in devstack

I still haven’t found any good documentation on setting up notifications. Most of the blog entries I’ve found are quite dated and don’t seem to apply to Mitaka-era installs. This is what I came up with (I think) in a devstack environment in /etc/nova/nova.conf:

notification_driver = messagingv2
notification_topics = notifications
notify_on_state_change = vm_state
notify_on_any_change = True

I’m still toying with this but wanted to put something down before I do something dumb like re-install devstack, like I did the last time I had it working and wiped out my configuration.

This is the python I’m using for now:

import json
from oslo_config import cfg
import oslo_messaging

class NotificationEndpoint(object):
    def info(self, ctxt, publisher_id, event_type, payload, metadata):
        print 'notification:'
        print json.dumps(payload, indent=4)
        print publisher_id
        print event_type
        print metadata

transport = oslo_messaging.get_transport(cfg.CONF)
targets = [ oslo_messaging.Target(topic='notifications') ]
endpoints = [ NotificationEndpoint() ]
server = oslo_messaging.get_notification_listener(transport, targets, endpoints)
print "Starting"
server.start()
#print "Waiting"
#server.wait()

Leave a Reply