root / settings.d / 15-queues.conf @ 9da33f32
History | View | Annotate | Download (2.6 kB)
1 |
# -*- coding: utf-8 -*- |
---|---|
2 |
# |
3 |
# Queues, exchanges and bindings for AMQP |
4 |
########################################### |
5 |
|
6 |
# Rabbit work queue endpoint |
7 |
RABBIT_HOST = "62.217.120.67:5672" |
8 |
RABBIT_USERNAME = "okeanos" |
9 |
RABBIT_PASSWORD = "0k3@n0s" |
10 |
RABBIT_VHOST = "/" |
11 |
|
12 |
EXCHANGE_GANETI = "ganeti" # Messages from Ganeti |
13 |
EXCHANGE_CRON = "cron" # Messages from periodically triggered tasks |
14 |
EXCHANGE_API = "api" # Messages from the REST API |
15 |
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API) |
16 |
|
17 |
QUEUE_GANETI_EVENTS = "events" |
18 |
QUEUE_CRON_CREDITS = "credits" |
19 |
QUEUE_EMAIL = "email" |
20 |
QUEUE_RECONC = "reconciliation" |
21 |
QUEUE_DEBUG = "debug" # Debug queue, retrieves all messages |
22 |
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC) |
23 |
|
24 |
BINDINGS_DEBUG = [ |
25 |
# Queue # Exchange # RouteKey # Handler |
26 |
(QUEUE_DEBUG, EXCHANGE_GANETI, '#', 'dummy_proc'), |
27 |
(QUEUE_DEBUG, EXCHANGE_CRON, '#', 'dummy_proc'), |
28 |
(QUEUE_DEBUG, EXCHANGE_API, '#', 'dummy_proc'), |
29 |
] |
30 |
|
31 |
BINDINGS = [ |
32 |
# Queue # Exchange # RouteKey # Handler |
33 |
(QUEUE_GANETI_EVENTS, EXCHANGE_GANETI, 'ganeti.*.event.op', 'update_db'), |
34 |
(QUEUE_GANETI_EVENTS, EXCHANGE_GANETI, 'ganeti.*.event.net', 'update_net'), |
35 |
(QUEUE_CRON_CREDITS, EXCHANGE_CRON, '*.credits.*', 'update_credits'), |
36 |
(QUEUE_EMAIL, EXCHANGE_API, '*.email.*', 'send_email'), |
37 |
(QUEUE_EMAIL, EXCHANGE_CRON, '*.email.*', 'send_email'), |
38 |
(QUEUE_RECONC, EXCHANGE_CRON, 'reconciliation.*', 'trigger_status_update'), |
39 |
] |
40 |
|
41 |
def fix_amqp_settings(backend_prefix): |
42 |
"""Configure AMQP-specific settings |
43 |
|
44 |
Configure AMQP-specific settings based on backend_prefix. |
45 |
This function *must* be called later in settings.py, with |
46 |
BACKEND_PREFIX_ID as argument. |
47 |
|
48 |
""" |
49 |
global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES |
50 |
|
51 |
prefix = backend_prefix.split('-')[0] |
52 |
# notifications of type "ganeti-op-status" |
53 |
DB_HANDLER_KEY_OP ='ganeti.%s.event.op' % prefix |
54 |
# notifications of type "ganeti-net-status" |
55 |
DB_HANDLER_KEY_NET ='ganeti.%s.event.net' % prefix |
56 |
BINDINGS[0] = ("events-%s-op" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db') |
57 |
BINDINGS[1] = ("events-%s-net" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net') |
58 |
QUEUES += ("events-%s-op" % prefix, "events-%s-net" % prefix) |
59 |
|
60 |
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID |
61 |
# Make sure to call it again, if you modify it at some later point |
62 |
fix_amqp_settings(BACKEND_PREFIX_ID) |