Revision 226f086a settings.d/15-queues.conf
b/settings.d/15-queues.conf | ||
---|---|---|
13 | 13 |
EXCHANGE_CRON = "cron" # Messages from periodically triggered tasks |
14 | 14 |
EXCHANGE_API = "api" # Messages from the REST API |
15 | 15 |
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API) |
16 |
|
|
17 |
def fix_amqp_settings(backend_prefix): |
|
18 |
"""Configure AMQP-specific settings |
|
19 |
|
|
20 |
Configure AMQP-specific settings based on backend_prefix. |
|
21 |
This function *must* be called later in settings.py, with |
|
22 |
BACKEND_PREFIX_ID as argument. |
|
23 |
|
|
24 |
""" |
|
25 |
global BINDINGS, QUEUES, QUEUE_DEBUG, BINDINGS_DEBUG |
|
26 |
|
|
27 |
BINDINGS = [] |
|
28 |
QUEUES = [] |
|
29 |
|
|
30 |
prefix = backend_prefix.split('-')[0] |
|
31 |
|
|
32 |
QUEUE_GANETI_EVENTS_OP = "%s-events-op" % prefix |
|
33 |
QUEUE_GANETI_EVENTS_NET = "%s-events-net" % prefix |
|
34 |
QUEUE_CRON_CREDITS = "%s-credits" % prefix |
|
35 |
QUEUE_EMAIL = "%s-email" % prefix |
|
36 |
QUEUE_RECONC = "%s-reconciliation" % prefix |
|
37 |
if DEBUG is True: |
|
38 |
QUEUE_DEBUG = "debug" # Debug queue, retrieves all messages |
|
39 |
|
|
40 |
QUEUES = (QUEUE_GANETI_EVENTS_OP, QUEUE_GANETI_EVENTS_NET, |
|
41 |
QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC) |
|
42 |
|
|
43 |
if DEBUG is True: |
|
44 |
BINDINGS_DEBUG = [ |
|
45 |
# Queue # Exchange # RouteKey # Handler |
|
46 |
(QUEUE_DEBUG, EXCHANGE_GANETI, '#', 'dummy_proc'), |
|
47 |
(QUEUE_DEBUG, EXCHANGE_CRON, '#', 'dummy_proc'), |
|
48 |
(QUEUE_DEBUG, EXCHANGE_API, '#', 'dummy_proc'), |
|
49 |
] |
|
50 |
QUEUES += (QUEUE_DEBUG,) |
|
51 |
|
|
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 |
|
|
57 |
BINDINGS = [ |
|
58 |
# Queue # Exchange # RouteKey # Handler |
|
59 |
(QUEUE_GANETI_EVENTS_OP, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db'), |
|
60 |
(QUEUE_GANETI_EVENTS_NET, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net'), |
|
61 |
(QUEUE_CRON_CREDITS, EXCHANGE_CRON, '*.credits.*', 'update_credits'), |
|
62 |
(QUEUE_EMAIL, EXCHANGE_API, '*.email.*', 'send_email'), |
|
63 |
(QUEUE_EMAIL, EXCHANGE_CRON, '*.email.*', 'send_email'), |
|
64 |
(QUEUE_RECONC, EXCHANGE_CRON, 'reconciliation.*', 'trigger_status_update'), |
|
65 |
] |
|
66 |
|
|
67 |
|
|
68 |
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID |
|
69 |
# Make sure to call it again, if you modify it at some later point |
|
70 |
fix_amqp_settings(BACKEND_PREFIX_ID) |
Also available in: Unified diff