Statistics
| Branch: | Tag: | Revision:

root / settings.d / 15-queues.conf @ ccd0d474

History | View | Annotate | Download (4.1 kB)

1 1277fb19 Vangelis Koukis
# -*- coding: utf-8 -*-
2 1277fb19 Vangelis Koukis
3 1277fb19 Vangelis Koukis
# Copyright 2011 GRNET S.A. All rights reserved.
4 1277fb19 Vangelis Koukis
# 
5 1277fb19 Vangelis Koukis
# Redistribution and use in source and binary forms, with or
6 1277fb19 Vangelis Koukis
# without modification, are permitted provided that the following
7 1277fb19 Vangelis Koukis
# conditions are met:
8 1277fb19 Vangelis Koukis
# 
9 1277fb19 Vangelis Koukis
#   1. Redistributions of source code must retain the above
10 1277fb19 Vangelis Koukis
#      copyright notice, this list of conditions and the following
11 1277fb19 Vangelis Koukis
#      disclaimer.
12 1277fb19 Vangelis Koukis
# 
13 1277fb19 Vangelis Koukis
#   2. Redistributions in binary form must reproduce the above
14 1277fb19 Vangelis Koukis
#      copyright notice, this list of conditions and the following
15 1277fb19 Vangelis Koukis
#      disclaimer in the documentation and/or other materials
16 1277fb19 Vangelis Koukis
#      provided with the distribution.
17 1277fb19 Vangelis Koukis
# 
18 1277fb19 Vangelis Koukis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19 1277fb19 Vangelis Koukis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 1277fb19 Vangelis Koukis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 1277fb19 Vangelis Koukis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22 1277fb19 Vangelis Koukis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 1277fb19 Vangelis Koukis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 1277fb19 Vangelis Koukis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 1277fb19 Vangelis Koukis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 1277fb19 Vangelis Koukis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1277fb19 Vangelis Koukis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 1277fb19 Vangelis Koukis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1277fb19 Vangelis Koukis
# POSSIBILITY OF SUCH DAMAGE.
30 1277fb19 Vangelis Koukis
# 
31 1277fb19 Vangelis Koukis
# The views and conclusions contained in the software and
32 1277fb19 Vangelis Koukis
# documentation are those of the authors and should not be
33 1277fb19 Vangelis Koukis
# interpreted as representing official policies, either expressed
34 1277fb19 Vangelis Koukis
# or implied, of GRNET S.A.
35 1277fb19 Vangelis Koukis
# 
36 1277fb19 Vangelis Koukis
# -*- coding: utf-8 -*-
37 1277fb19 Vangelis Koukis
38 1277fb19 Vangelis Koukis
#
39 1277fb19 Vangelis Koukis
# Queues, exchanges and bindings for AMQP
40 1277fb19 Vangelis Koukis
###########################################
41 1277fb19 Vangelis Koukis
42 1277fb19 Vangelis Koukis
# Rabbit work queue endpoint
43 1277fb19 Vangelis Koukis
RABBIT_HOST = "62.217.120.67:5672"
44 1277fb19 Vangelis Koukis
RABBIT_USERNAME = "okeanos"
45 1277fb19 Vangelis Koukis
RABBIT_PASSWORD = "0k3@n0s"
46 1277fb19 Vangelis Koukis
RABBIT_VHOST = "/"
47 1277fb19 Vangelis Koukis
48 1277fb19 Vangelis Koukis
EXCHANGE_GANETI = "ganeti"  # Messages from Ganeti
49 1277fb19 Vangelis Koukis
EXCHANGE_CRON = "cron"      # Messages from periodically triggered tasks
50 1277fb19 Vangelis Koukis
EXCHANGE_API = "api"        # Messages from the REST API
51 1277fb19 Vangelis Koukis
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API)
52 1277fb19 Vangelis Koukis
53 1277fb19 Vangelis Koukis
QUEUE_GANETI_EVENTS = "events"
54 1277fb19 Vangelis Koukis
QUEUE_CRON_CREDITS = "credits"
55 1277fb19 Vangelis Koukis
QUEUE_EMAIL = "email"
56 1277fb19 Vangelis Koukis
QUEUE_RECONC = "reconciliation"
57 1277fb19 Vangelis Koukis
QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
58 1277fb19 Vangelis Koukis
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC)
59 1277fb19 Vangelis Koukis
60 1277fb19 Vangelis Koukis
BINDINGS_DEBUG = [
61 1277fb19 Vangelis Koukis
    # Queue         # Exchange          # RouteKey  # Handler
62 1277fb19 Vangelis Koukis
    (QUEUE_DEBUG,   EXCHANGE_GANETI,    '#',        'dummy_proc'),
63 1277fb19 Vangelis Koukis
    (QUEUE_DEBUG,   EXCHANGE_CRON,      '#',        'dummy_proc'),
64 1277fb19 Vangelis Koukis
    (QUEUE_DEBUG,   EXCHANGE_API,       '#',        'dummy_proc'),
65 1277fb19 Vangelis Koukis
]
66 1277fb19 Vangelis Koukis
67 1277fb19 Vangelis Koukis
BINDINGS = [
68 1277fb19 Vangelis Koukis
    # Queue                 # Exchange          # RouteKey            # Handler
69 1277fb19 Vangelis Koukis
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.op',  'update_db'),
70 1277fb19 Vangelis Koukis
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.net', 'update_net'),
71 1277fb19 Vangelis Koukis
    (QUEUE_CRON_CREDITS,    EXCHANGE_CRON,      '*.credits.*',        'update_credits'),
72 1277fb19 Vangelis Koukis
    (QUEUE_EMAIL,           EXCHANGE_API,       '*.email.*',          'send_email'),
73 1277fb19 Vangelis Koukis
    (QUEUE_EMAIL,           EXCHANGE_CRON,      '*.email.*',          'send_email'),
74 1277fb19 Vangelis Koukis
    (QUEUE_RECONC,          EXCHANGE_CRON,      'reconciliation.*',   'trigger_status_update'),
75 1277fb19 Vangelis Koukis
]
76 1277fb19 Vangelis Koukis
77 1277fb19 Vangelis Koukis
def fix_amqp_settings(backend_prefix):
78 1277fb19 Vangelis Koukis
    """Configure AMQP-specific settings
79 1277fb19 Vangelis Koukis
80 1277fb19 Vangelis Koukis
    Configure AMQP-specific settings based on backend_prefix.
81 1277fb19 Vangelis Koukis
    This function *must* be called later in settings.py, with
82 1277fb19 Vangelis Koukis
    BACKEND_PREFIX_ID as argument.
83 1277fb19 Vangelis Koukis
84 1277fb19 Vangelis Koukis
    """
85 1277fb19 Vangelis Koukis
    global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES
86 1277fb19 Vangelis Koukis
87 1277fb19 Vangelis Koukis
    prefix = backend_prefix.split('-')[0]
88 1277fb19 Vangelis Koukis
    # notifications of type "ganeti-op-status"
89 1277fb19 Vangelis Koukis
    DB_HANDLER_KEY_OP ='ganeti.%s.event.op' % prefix 
90 1277fb19 Vangelis Koukis
    # notifications of type "ganeti-net-status"
91 1277fb19 Vangelis Koukis
    DB_HANDLER_KEY_NET ='ganeti.%s.event.net' % prefix
92 1277fb19 Vangelis Koukis
    BINDINGS[0] = ("events-%s-op" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db')
93 1277fb19 Vangelis Koukis
    BINDINGS[1] = ("events-%s-net" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net')
94 1277fb19 Vangelis Koukis
    QUEUES += ("events-%s-op" % prefix, "events-%s-net" % prefix)
95 1277fb19 Vangelis Koukis
96 1277fb19 Vangelis Koukis
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID
97 1277fb19 Vangelis Koukis
# Make sure to call it again, if you modify it at some later point
98 1277fb19 Vangelis Koukis
fix_amqp_settings(BACKEND_PREFIX_ID)