1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

AC-1012 Force use of pyamqp even if librabbitmq is installed.

This commit is contained in:
Chris Church 2014-02-07 20:03:42 -05:00
parent cac49c199c
commit b708edffd9

View File

@ -51,6 +51,13 @@ except ImportError:
import requests import requests
from kombu import Connection, Exchange, Queue from kombu import Connection, Exchange, Queue
# Check to see if librabbitmq is installed.
try:
import librabbitmq
LIBRABBITMQ_INSTALLED = True
except ImportError:
LIBRABBITMQ_INSTALLED = False
class TokenAuth(requests.auth.AuthBase): class TokenAuth(requests.auth.AuthBase):
@ -88,6 +95,12 @@ class CallbackModule(object):
self.auth_token = os.getenv('REST_API_TOKEN', '') self.auth_token = os.getenv('REST_API_TOKEN', '')
self.broker_url = os.getenv('BROKER_URL', '') self.broker_url = os.getenv('BROKER_URL', '')
self._init_logging() self._init_logging()
# Since we don't yet have a way to confirm publish when using
# librabbitmq, ensure we use pyamqp even if librabbitmq happens to be
# installed.
if LIBRABBITMQ_INSTALLED:
self.logger.info('Forcing use of pyamqp instead of librabbitmq')
self.broker_url = self.broker_url.replace('amqp://', 'pyamqp://')
def _init_logging(self): def _init_logging(self):
try: try: