Statistics
| Branch: | Tag: | Revision:

root / settings.d / 15-queues.conf @ 32ef827c

History | View | Annotate | Download (4.2 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
def fix_amqp_settings(backend_prefix):
54
    """Configure AMQP-specific settings
55

    
56
    Configure AMQP-specific settings based on backend_prefix.
57
    This function *must* be called later in settings.py, with
58
    BACKEND_PREFIX_ID as argument.
59

    
60
    """
61
    global BINDINGS, QUEUES, QUEUE_DEBUG, BINDINGS_DEBUG
62

    
63
    BINDINGS = []
64
    QUEUES = []
65

    
66
    prefix = backend_prefix.split('-')[0]
67

    
68
    QUEUE_GANETI_EVENTS_OP = "%s-events-op" % prefix
69
    QUEUE_GANETI_EVENTS_NET = "%s-events-net" % prefix
70
    QUEUE_CRON_CREDITS = "%s-credits" % prefix
71
    QUEUE_EMAIL = "%s-email" % prefix
72
    QUEUE_RECONC = "%s-reconciliation" % prefix
73
    if DEBUG is True:
74
        QUEUE_DEBUG = "debug"       # Debug queue, retrieves all messages
75

    
76
    QUEUES = (QUEUE_GANETI_EVENTS_OP, QUEUE_GANETI_EVENTS_NET,
77
              QUEUE_CRON_CREDITS, QUEUE_EMAIL, QUEUE_RECONC)
78

    
79
    if DEBUG is True:
80
        BINDINGS_DEBUG = [
81
        # Queue         # Exchange          # RouteKey  # Handler
82
        (QUEUE_DEBUG,   EXCHANGE_GANETI,    '#',        'dummy_proc'),
83
        (QUEUE_DEBUG,   EXCHANGE_CRON,      '#',        'dummy_proc'),
84
        (QUEUE_DEBUG,   EXCHANGE_API,       '#',        'dummy_proc'),
85
        ]
86
        QUEUES += (QUEUE_DEBUG,)
87

    
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

    
93
    BINDINGS = [
94
    # Queue                     # Exchange          # RouteKey              # Handler
95
    (QUEUE_GANETI_EVENTS_OP,    EXCHANGE_GANETI,    'ganeti.*.event.op',    'update_db'),
96
    (QUEUE_GANETI_EVENTS_NET,   EXCHANGE_GANETI,    'ganeti.*.event.net',   'update_net'),
97
    (QUEUE_CRON_CREDITS,        EXCHANGE_CRON,      '*.credits.*',          'update_credits'),
98
    (QUEUE_EMAIL,               EXCHANGE_API,       '*.email.*',            'send_email'),
99
    (QUEUE_EMAIL,               EXCHANGE_CRON,      '*.email.*',            'send_email'),
100
    (QUEUE_RECONC,              EXCHANGE_CRON,      'reconciliation.*',     'trigger_status_update'),
101
    ]
102

    
103

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