[openstack-dev] [oslo_messaging]Notification listener for nova

Eduard Matei eduard.matei at cloudfounders.com
Wed Mar 4 07:14:27 UTC 2015


Hi,
I'm trying to listen to events of type "compute.instance.*" (e.g.
compute.instance.update).
I tried the following code:

from oslo_config import cfg
import oslo_messaging

class NotificationEndpoint(object):
    filter_rule =
oslo_messaging.NotificationFilter(publisher_id='compute.*',

event_type='compute.instance.update',
                                                    context={'ctxt_key':
'regexp'})

    def info(self, ctxt, publisher_id, event_type, payload, metadata):
        print(payload)

    def warn(self, ctxt, publisher_id, event_type, payload, metadata):
        print(payload)

transport = oslo_messaging.get_transport(cfg.CONF)
targets = [oslo_messaging.Target(topic='notifications'),
           oslo_messaging.Target(topic='notifications_bis')]
endpoints = [NotificationEndpoint()]
pool = "listener-workers"
server = oslo_messaging.get_notification_listener(transport=transport,
                                                  targets=targets,
                                                  endpoints=endpoints,
                                                  pool=pool)
server.start()
server.wait()

then, from Horizon i changed an instance name (which should call
_send_instance_update_notification)  but i didn't get any notification.

Any ideas?
Thanks,

-- 

*Eduard Biceri Matei, Senior Software Developer*
www.cloudfounders.com
 | eduard.matei at cloudfounders.com



*CloudFounders, The Private Cloud Software Company*

Disclaimer:
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed.
If you are not the named addressee or an employee or agent responsible
for delivering this message to the named addressee, you are hereby
notified that you are not authorized to read, print, retain, copy or
disseminate this message or any part of it. If you have received this
email in error we request you to notify us by reply e-mail and to
delete all electronic files of the message. If you are not the
intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
information is strictly prohibited.
E-mail transmission cannot be guaranteed to be secure or error free as
information could be intercepted, corrupted, lost, destroyed, arrive
late or incomplete, or contain viruses. The sender therefore does not
accept liability for any errors or omissions in the content of this
message, and shall have no liability for any loss or damage suffered
by the user, which arise as a result of e-mail transmission.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150304/c4ff7841/attachment.html>


More information about the OpenStack-dev mailing list