Skip to content

Instantly share code, notes, and snippets.

@haneefs
Created October 12, 2015 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haneefs/ecf97b20ec00ee0b0da1 to your computer and use it in GitHub Desktop.
Save haneefs/ecf97b20ec00ee0b0da1 to your computer and use it in GitHub Desktop.
Keystone audit client
#!/usr/bin/env python
import pika
# Username/Password for rabbit
credentials = pika.PlainCredentials("guest", "I5Tldwxd")
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='192.168.245.3', port=5672, credentials=credentials))
channel = connection.channel()
# Keystone sends the message to the exchange=keystone
channel.exchange_declare(exchange='keystone',
type='topic')
# Create a random queue and connect to the exchange
# Make sure this queue is exclusive to auditclient and non persistent.
# If you make the queue to be persistent, you have to make sure that queue doesn't get staturated with
# too many many messaages
result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue
# Binding keys used by keystone
binding_keys = ["notifications.info"]
for binding_key in binding_keys:
channel.queue_bind(exchange='keystone',
queue=queue_name,
routing_key=binding_key)
print ' [*] Waiting for audit messages. To exit press CTRL+C'
def callback(ch, method, properties, body):
print " [x] %r:%r" % (method.routing_key, body,)
channel.basic_consume(callback,
queue=queue_name,
no_ack=True)
channel.start_consuming()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment