mirror of
https://github.com/ansible/awx.git
synced 2026-04-06 18:49:21 -02:30
AC-752 Update settings to support enabling celeryd using rabbitmq on upgrade, also support config files in /etc/awx/conf.d/.
This commit is contained in:
@@ -18,6 +18,7 @@ django-auth-ldap==1.1.6 (django_auth_ldap/*)
|
||||
django-celery==3.1.1 (djcelery/*)
|
||||
django-extensions==1.2.5 (django_extensions/*)
|
||||
django-jsonfield==0.9.11 (jsonfield/*)
|
||||
django-split-settings==0.1.1 (split_settings/*)
|
||||
django-taggit==0.10 (taggit/*)
|
||||
djangorestframework==2.3.8 (rest_framework/*)
|
||||
httplib2==0.8 (httplib2/*)
|
||||
|
||||
1
awx/lib/site-packages/split_settings/__init__.py
Normal file
1
awx/lib/site-packages/split_settings/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = '0.1.1'
|
||||
67
awx/lib/site-packages/split_settings/tools.py
Normal file
67
awx/lib/site-packages/split_settings/tools.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
|
||||
class optional(str):
|
||||
"""Wrap a file path with this class to mark it as optional.
|
||||
|
||||
Optional paths don't raise an IOError if file is not found.
|
||||
"""
|
||||
pass
|
||||
|
||||
def include(*args, **kwargs):
|
||||
"""Used for including Django project settings from multiple files.
|
||||
|
||||
Note: Expects to get ``scope=locals()`` as a keyword argument.
|
||||
|
||||
Usage::
|
||||
|
||||
from split_settings.tools import optional, include
|
||||
|
||||
include(
|
||||
'components/base.py',
|
||||
'components/database.py',
|
||||
optional('local_settings.py'),
|
||||
|
||||
scope=locals()
|
||||
)
|
||||
|
||||
Parameters:
|
||||
*args: File paths (``glob``-compatible wildcards can be used)
|
||||
scope: The context for the settings, should always be ``locals()``
|
||||
Raises:
|
||||
IOError: if a required settings file is not found
|
||||
|
||||
"""
|
||||
scope = kwargs.pop("scope")
|
||||
including_file = scope.get('__included_file__',
|
||||
scope['__file__'].rstrip('c'))
|
||||
confpath = os.path.dirname(including_file)
|
||||
for conffile in args:
|
||||
saved_included_file = scope.get('__included_file__')
|
||||
pattern = os.path.join(confpath, conffile)
|
||||
|
||||
# find files per pattern, raise an error if not found (unless file is
|
||||
# optional)
|
||||
files_to_include = glob.glob(pattern)
|
||||
if not files_to_include and not isinstance(conffile, optional):
|
||||
raise IOError('No such file: %s' % pattern)
|
||||
|
||||
for included_file in files_to_include:
|
||||
scope['__included_file__'] = included_file
|
||||
execfile(included_file, {}, scope)
|
||||
|
||||
# add dummy modules to sys.modules to make runserver autoreload
|
||||
# work with settings components
|
||||
modulename = ('_split_settings.%s'
|
||||
% conffile[:conffile.rfind('.')].replace('/', '.'))
|
||||
module = types.ModuleType(modulename)
|
||||
module.__file__ = included_file
|
||||
sys.modules[modulename] = module
|
||||
if saved_included_file:
|
||||
scope['__included_file__'] = saved_included_file
|
||||
elif '__included_file__' in scope:
|
||||
del scope['__included_file__']
|
||||
Reference in New Issue
Block a user