Python script to monitor and handler events from Openstack neutron. This script create a queue with auto_delete
feature binding to neutron
exchange with routing_key
equal to notifications.info
pip install -r requirements.txt
python fliatingip_handler.py -c floatingip_handler.config.example
[Default]
debug = False
[RabbitMQ]
monitoring_queue_name = floatingip
rabbitmq_hosts = rabbitmq01,rabbitmq02,rabbitmq03
rabbitmq_port = 5672
user = guest
pass = guest
Options:
debug
: Enable or disable debug trace logs.monitoring_queue_name
: RabbitMQ queue name to create and manage (auto_delete queue)rabbitmq_hosts
: Comman-separated list of rabbitmq serversrabbitmq_port
: RabbitMQ portuser
: RabbitMQ user namepass
: RabbitMQ password
By default, no action is configure to do either UP or DOWN floating IP. If you want to handler these actions you should modified the code. There are 2 functions on the top of script:
callback_create_floating_ip
: Handler function for floating IP associationcallback_delete_floating_ip
: Handler function for floating IP disassociation
An example:
from httplib2 import Http
def callback_delete_floating_ip(data):
"""Callback function for floating ip disassociation"""
h = Http()
print " * Floating IP %s disassociated" % data['floating_ip_address']
unregister = json.loads(urllib2.urlopen("http://10.10.10.10/release/ipv4address?ip_address="+data['floating_ip_address']).read())
sh test.sh
In this repo there are other scripts with similar installation, configuration and working
network_handler.py
: listen for network creation / delete operations