~nova-coresec/nova/bexar-translations

« back to all changes in this revision

Viewing changes to nova/fakerabbit.py

  • Committer: Todd Willey
  • Date: 2011-01-04 05:23:35 UTC
  • mto: (515.6.1 newlog2)
  • mto: This revision was merged to the branch mainline in revision 528.
  • Revision ID: todd@ansolabs.com-20110104052335-rfq4igtasqjv3ux5
Apply logging changes as a giant patch to work around the cloudpipe delete + add issue in the original patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""Based a bit on the carrot.backeds.queue backend... but a lot better."""
20
20
 
21
 
import logging
22
21
import Queue as queue
23
22
 
24
23
from carrot.backends import base
25
24
from eventlet import greenthread
26
25
 
 
26
from nova import log as logging
 
27
 
 
28
 
 
29
LOG = logging.getLogger("nova.fakerabbit")
 
30
 
27
31
 
28
32
EXCHANGES = {}
29
33
QUEUES = {}
41
45
        self._routes = {}
42
46
 
43
47
    def publish(self, message, routing_key=None):
44
 
        logging.debug(_('(%s) publish (key: %s) %s'),
45
 
                      self.name, routing_key, message)
 
48
        LOG.debug(_('(%s) publish (key: %s) %s'),
 
49
                  self.name, routing_key, message)
46
50
        routing_key = routing_key.split('.')[0]
47
51
        if routing_key in self._routes:
48
52
            for f in self._routes[routing_key]:
49
 
                logging.debug(_('Publishing to route %s'), f)
 
53
                LOG.debug(_('Publishing to route %s'), f)
50
54
                f(message, routing_key=routing_key)
51
55
 
52
56
    def bind(self, callback, routing_key):
76
80
    def queue_declare(self, queue, **kwargs):
77
81
        global QUEUES
78
82
        if queue not in QUEUES:
79
 
            logging.debug(_('Declaring queue %s'), queue)
 
83
            LOG.debug(_('Declaring queue %s'), queue)
80
84
            QUEUES[queue] = Queue(queue)
81
85
 
82
86
    def exchange_declare(self, exchange, type, *args, **kwargs):
83
87
        global EXCHANGES
84
88
        if exchange not in EXCHANGES:
85
 
            logging.debug(_('Declaring exchange %s'), exchange)
 
89
            LOG.debug(_('Declaring exchange %s'), exchange)
86
90
            EXCHANGES[exchange] = Exchange(exchange, type)
87
91
 
88
92
    def queue_bind(self, queue, exchange, routing_key, **kwargs):
89
93
        global EXCHANGES
90
94
        global QUEUES
91
 
        logging.debug(_('Binding %s to %s with key %s'),
 
95
        LOG.debug(_('Binding %s to %s with key %s'),
92
96
                      queue, exchange, routing_key)
93
97
        EXCHANGES[exchange].bind(QUEUES[queue].push, routing_key)
94
98
 
113
117
                          content_type=content_type,
114
118
                          content_encoding=content_encoding)
115
119
        message.result = True
116
 
        logging.debug(_('Getting from %s: %s'), queue, message)
 
120
        LOG.debug(_('Getting from %s: %s'), queue, message)
117
121
        return message
118
122
 
119
123
    def prepare_message(self, message_data, delivery_mode,