aws.py 2.11 KB
Newer Older
1 2 3 4 5 6
"""
This is the default template for our main set of AWS servers.
"""
import json

from .common import *
7
from logsettings import get_logger_config
8 9 10 11 12 13 14 15 16 17 18 19 20 21
import os

# specified as an environment variable.  Typically this is set
# in the service's upstart script and corresponds exactly to the service name.
# Service variants apply config differences via env and auth JSON files,
# the names of which correspond to the variant.
SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)

# when not variant is specified we attempt to load an unvaried
# config set.
CONFIG_PREFIX = ""

if SERVICE_VARIANT:
    CONFIG_PREFIX = SERVICE_VARIANT + "."
22

John Jarvis committed
23
############### ALWAYS THE SAME ################################
24 25 26 27 28 29 30
DEBUG = False
TEMPLATE_DEBUG = False

EMAIL_BACKEND = 'django_ses.SESBackend'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

John Jarvis committed
31
############# NON-SECURE ENV CONFIG ##############################
32
# Things like server locations, ports, etc.
33
with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file:
34 35
    ENV_TOKENS = json.load(env_file)

36
LMS_BASE = ENV_TOKENS.get('LMS_BASE')
37

38 39 40 41 42 43
SITE_NAME = ENV_TOKENS['SITE_NAME']

LOG_DIR = ENV_TOKENS['LOG_DIR']

CACHES = ENV_TOKENS['CACHES']

44 45
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')

46 47 48 49 50 51
for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items():
    MITX_FEATURES[feature] = value

LOGGING = get_logger_config(LOG_DIR,
                            logging_env=ENV_TOKENS['LOGGING_ENV'],
                            syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
John Jarvis committed
52 53
                            debug=False,
                            service_variant=SERVICE_VARIANT)
54

John Jarvis committed
55
################ SECURE AUTH ITEMS ###############################
56
# Secret things: passwords, access keys, etc.
57
with open(ENV_ROOT / CONFIG_PREFIX + "auth.json") as auth_file:
58 59
    AUTH_TOKENS = json.load(auth_file)

60 61
AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
62 63
DATABASES = AUTH_TOKENS['DATABASES']
MODULESTORE = AUTH_TOKENS['MODULESTORE']
64
CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE']