Initial qpid development work

* Switch base tower devel image from u14.04 to c7
* Switch container image to build python dependencies into itself
  instead of forcing it to be built on startup
* Upgrade venv pip to 8.1.2
* Neuter queue.py which was heavily tied to redis and was basically
  orphaned code
* Alter local_settings to override default cache settings and use
  memcached
* Alter local settings to refer to qpid instead of redis for celery
  broker
* Purge redis python dependencies and add qpid and memcached
* Update docker-compose to purge redis and add qpid and memcached
This commit is contained in:
Matthew Jones
2016-08-24 16:23:47 -04:00
parent 25fa05da81
commit dcb4959443
11 changed files with 80 additions and 72 deletions

View File

@@ -3,43 +3,11 @@
import json
from redis import StrictRedis
from django.conf import settings
__all__ = ['FifoQueue']
# Determine, based on settings.BROKER_URL (for celery), what the correct Redis
# connection settings are.
redis_kwargs = {}
broker_url = settings.BROKER_URL
if not broker_url.lower().startswith('redis://'):
raise RuntimeError('Error importing awx.main.queue: Cannot use queue with '
'a non-Redis broker configured for celery.\n'
'Broker is set to: %s' % broker_url)
broker_url = broker_url[8:]
# There may or may not be a password; address both situations by checking
# for an "@" in the broker URL.
if '@' in broker_url:
broker_auth, broker_host = broker_url.split('@')
redis_kwargs['password'] = broker_auth.split(':')[1]
else:
broker_host = broker_url
# Ignore anything after a / in the broker host.
broker_host = broker_host.split('/')[0]
# If a custom port is present, parse it out.
if ':' in broker_host:
broker_host, broker_port = broker_host.split(':')
redis_kwargs['port'] = int(broker_port)
# Now create a StrictRedis object that knows how to connect appropriately.
redis = StrictRedis(broker_host, **redis_kwargs)
# TODO: Figure out wtf to do with this class
class FifoQueue(object):
"""An abstraction class implemented for a simple push/pull queue.
@@ -54,14 +22,16 @@ class FifoQueue(object):
def __len__(self):
"""Return the length of the Redis list."""
return redis.llen(self._queue_name)
#return redis.llen(self._queue_name)
return 0
def push(self, value):
"""Push a value onto the right side of the queue."""
redis.rpush(self._queue_name, json.dumps(value))
#redis.rpush(self._queue_name, json.dumps(value))
def pop(self):
"""Retrieve a value from the left side of the queue."""
answer = redis.lpop(self._queue_name)
#answer = redis.lpop(self._queue_name)
answer = None
if answer:
return json.loads(answer)