Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (4.1 kB)

1
# -*- coding: utf-8 -*-
2

    
3
# Copyright 2011 GRNET S.A. All rights reserved.
4
# 
5
# Redistribution and use in source and binary forms, with or
6
# without modification, are permitted provided that the following
7
# conditions are met:
8
# 
9
#   1. Redistributions of source code must retain the above
10
#      copyright notice, this list of conditions and the following
11
#      disclaimer.
12
# 
13
#   2. Redistributions in binary form must reproduce the above
14
#      copyright notice, this list of conditions and the following
15
#      disclaimer in the documentation and/or other materials
16
#      provided with the distribution.
17
# 
18
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
30
# 
31
# The views and conclusions contained in the software and
32
# documentation are those of the authors and should not be
33
# interpreted as representing official policies, either expressed
34
# or implied, of GRNET S.A.
35
# 
36
# -*- coding: utf-8 -*-
37

    
38
#
39
# Queues, exchanges and bindings for AMQP
40
###########################################
41

    
42
# Rabbit work queue endpoint
43
RABBIT_HOST = "62.217.120.67:5672"
44
RABBIT_USERNAME = "okeanos"
45
RABBIT_PASSWORD = "0k3@n0s"
46
RABBIT_VHOST = "/"
47

    
48
EXCHANGE_GANETI = "ganeti"  # Messages from Ganeti
49
EXCHANGE_CRON = "cron"      # Messages from periodically triggered tasks
50
EXCHANGE_API = "api"        # Messages from the REST API
51
EXCHANGES = (EXCHANGE_GANETI, EXCHANGE_CRON, EXCHANGE_API)
52

    
53
QUEUE_GANETI_EVENTS = "events"
54
QUEUE_CRON_CREDITS = "credits"
55
QUEUE_EMAIL = "email"
56
QUEUE_RECONC = "reconciliation"
57
QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
58
QUEUES = (QUEUE_GANETI_EVENTS, QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC)
59

    
60
BINDINGS_DEBUG = [
61
    # Queue         # Exchange          # RouteKey  # Handler
62
    (QUEUE_DEBUG,   EXCHANGE_GANETI,    '#',        'dummy_proc'),
63
    (QUEUE_DEBUG,   EXCHANGE_CRON,      '#',        'dummy_proc'),
64
    (QUEUE_DEBUG,   EXCHANGE_API,       '#',        'dummy_proc'),
65
]
66

    
67
BINDINGS = [
68
    # Queue                 # Exchange          # RouteKey            # Handler
69
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.op',  'update_db'),
70
    (QUEUE_GANETI_EVENTS,   EXCHANGE_GANETI,    'ganeti.*.event.net', 'update_net'),
71
    (QUEUE_CRON_CREDITS,    EXCHANGE_CRON,      '*.credits.*',        'update_credits'),
72
    (QUEUE_EMAIL,           EXCHANGE_API,       '*.email.*',          'send_email'),
73
    (QUEUE_EMAIL,           EXCHANGE_CRON,      '*.email.*',          'send_email'),
74
    (QUEUE_RECONC,          EXCHANGE_CRON,      'reconciliation.*',   'trigger_status_update'),
75
]
76

    
77
def fix_amqp_settings(backend_prefix):
78
    """Configure AMQP-specific settings
79

    
80
    Configure AMQP-specific settings based on backend_prefix.
81
    This function *must* be called later in settings.py, with
82
    BACKEND_PREFIX_ID as argument.
83

    
84
    """
85
    global DB_HANDLER_KEY_OP, DB_HANDLER_KEY_NET, BINDINGS, QUEUES
86

    
87
    prefix = backend_prefix.split('-')[0]
88
    # notifications of type "ganeti-op-status"
89
    DB_HANDLER_KEY_OP ='ganeti.%s.event.op' % prefix 
90
    # notifications of type "ganeti-net-status"
91
    DB_HANDLER_KEY_NET ='ganeti.%s.event.net' % prefix
92
    BINDINGS[0] = ("events-%s-op" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_OP, 'update_db')
93
    BINDINGS[1] = ("events-%s-net" % prefix, EXCHANGE_GANETI, DB_HANDLER_KEY_NET, 'update_net')
94
    QUEUES += ("events-%s-op" % prefix, "events-%s-net" % prefix)
95

    
96
# Fix up the AMQP-specific settings based on BACKEND_PREFIX_ID
97
# Make sure to call it again, if you modify it at some later point
98
fix_amqp_settings(BACKEND_PREFIX_ID)