Home > openstack > Intercepting internal messages from RabbitMQ in OpenStack Nova

Intercepting internal messages from RabbitMQ in OpenStack Nova

Suppose, you are the OpenStack Cloud Admin of your company and you want whenever, a new vm is created or updated or deleted you want to be informed of the details. Similarly, you need to know (as a admin) about various other  cloud actions(snapshot creation, vm resize and so on). Typically, each action send one or more notification. For example, when booting a new VM, four different (but co-related) notifications are sent.

Event_type extracted from a notification messages associated with vm creation process are :


Limited details of the compute.instance.update message associated with vm creation process is follows:



The following is an excerpt from nova scheduler showing sendings a notification named *scheduler.run_instance.start* for the vm creation process.


Now, We need to know where these notifications are sent and how to capture them. In fact, these notifications are being sent to message queues named notifications.info, notification.error.


Above figure, shows two different queues named ‘notifications.info’ and ‘notifications.error’ which capture info messages and error messages correspondingly.

We can fetch this notifications messages in following ways out of many possibilities.

1. Attach a consumer to the notifications.info or notifications.error queue. In some cases, attaching a consumer may not be desirable if there are multiple consumer which forces the messages to be dispatched to the consumer in a round-robin fashion.

2. Intercept the notification messages from the “nova” exchange and attach your own queue for notifications in which case notifications are forward to the newly defined queue as well as predefined ‘notification.info’ queues.

Following code snippet shows how to connect to the notifications.info queue and extract notification messages.

import pika
class MessageBroker:</code>

def __init__(self):
    queue_name = 'notifications.info'
    parameters = pika.URLParameters('amqp://guest:admin@localhost:5672/%2F') #my      devstack conf.
    connection = pika.BlockingConnection(parameters)

    channel = connection.channel()
    channel.queue_declare(queue= queue_name)
    print ' [*] Waiting for messages. To exit press CTRL+C'
    queue= queue_name,no_ack=True)


    def callback(self, ch, method, properties, body):

    print body
    print "\n"

def receive_message():

  1. May 8, 2014 at 1:10 am

    Thanks for writing about Notification in Openstack.

    What sort of changes needed in nova.conf, and can we create/modify notifications?

  2. June 1, 2015 at 12:48 am

    Inspired by your article I created a Nova notification listener using Kombu messaging library:

    Blogpost explains the necessary Nova configuration, too.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: