Moved RabbitMQ sniffer - rabbit.py - as part of user-api scripts

This commit is contained in:
Murali Raju 2012-09-12 15:03:17 -04:00
parent f61bac960e
commit 5e24bec3dc
2 changed files with 75 additions and 0 deletions

37
scripts/devstack_mysql.py Normal file
View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy import MetaData, Column, Table, ForeignKey
from sqlalchemy import Integer, String
try:
engine = sqlalchemy.create_engine('mysql://root:openstack@localhost')
metadata = MetaData(bind=engine)
except Exception, e:
raise e
engine.execute("USE ovs_quantum")
subnets = engine.execute('select * from subnets limit 1')
engine.execute("USE ovs_quantum")
networks = engine.execute('select * from networks limit 1')
def construct_sql():
for row in subnets:
print "subnet id: ", row['id']
subnet_id = row['id']
for row in networks:
print "network id: ", row['id']
network_id = row['id']
ipallocations_table = sqlalchemy.Table("ipallocations",
metadata, autoload=True)
insert_sql = ipallocations_table.insert()
insert_sql.execute(id='73ed9ee0-fd02-11e1-a21f-0800200c9a66',
subnet_id=subnet_id, network_id=network_id,
ip_address='172.16.20.1')
construct_sql()

38
scripts/rabbit.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python
#
# Usage: python rabbit.py '#'
#
import pika
import sys
credentials = pika.PlainCredentials('guest', 'yetanothersecret')
connection = pika.BlockingConnection(pika.ConnectionParameters
(host='192.168.57.100', credentials=credentials))
channel = connection.channel()
channel.exchange_declare(exchange='quantum',
type='topic')
result = channel.queue_declare(exclusive=False)
queue_name = result.method.queue
binding_keys = sys.argv[1:]
if not binding_keys:
print >> sys.stderr, "Usage: %s [binding_key]..." % (sys.argv[0],)
sys.exit(1)
for binding_key in binding_keys:
channel.queue_bind(exchange='quantum',
queue=queue_name,
routing_key=binding_key)
print ' [*] Waiting for logs. 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()