config.py 2.82 KB
Newer Older
Markus Scheidgen's avatar
Markus Scheidgen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright 2018 Markus Scheidgen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an"AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
16
17
18
19
"""
This module is used to store all configuration values. It makes use of
*namedtuples* to create key sensitive configuration objects.
"""

20
import os
21
22
from collections import namedtuple

23
24
FilesConfig = namedtuple(
    'FilesConfig', ['uploads_bucket', 'repository_bucket', 'archive_bucket', 'compress_archive'])
25
26
""" API independent configuration for the object storage. """

27
CeleryConfig = namedtuple('Celery', ['broker_url', 'backend_url', 'serializer'])
28
""" Used to configure the RabbitMQ and Redis backends for celery. """
29

30
MinioConfig = namedtuple('Minio', ['host', 'port', 'accesskey', 'secret'])
31
32
""" Used to configure the minio object storage API. """

33
FSConfig = namedtuple('FSConfig', ['tmp'])
34
35
""" Used to configure file stystem access. """

36
37
38
39
40
41
ElasticConfig = namedtuple('ElasticConfig', ['host', 'calc_index'])
""" Used to configure elastic search. """

MongoConfig = namedtuple('MongoConfig', ['host', 'users_db'])
""" Used to configure mongo db. """

42
LogstashConfig = namedtuple('LogstashConfig', ['enabled', 'host', 'tcp_port'])
43
""" Used to configure and enable/disable the ELK based centralized logging. """
44

45
files = FilesConfig(
46
47
    uploads_bucket='uploads',
    repository_bucket='repository',
48
49
    archive_bucket='archive',
    compress_archive=False
50
)
51
52
53
54
55
56
57
58
59
60

rabbit_host = os.environ.get('NOMAD_RABBITMQ_HOST', 'localhost')
rabbit_port = os.environ.get('NOMAD_RABBITMQ_PORT', None)
rabbit_user = 'rabbitmq'
rabbit_password = 'rabbitmq'
redis_host = os.environ.get('NOMAD_REDIS_HOST', 'localhost')

rabbit_url = 'pyamqp://%s:%s@%s//' % (rabbit_user, rabbit_password, rabbit_host)
redis_url = 'redis://%s/0' % redis_host

61
celery = CeleryConfig(
62
63
64
    broker_url=redis_url,
    backend_url=redis_url,
    serializer='pickle'
65
)
66

67
minio = MinioConfig(
68
69
    host=os.environ.get('NOMAD_MINIO_HOST', 'localhost'),
    port=int(os.environ.get('NOMAD_MINIO_PORT', '9007')),
70
71
    accesskey='AKIAIOSFODNN7EXAMPLE',
    secret='wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
72
73
)
fs = FSConfig(
74
    tmp='.volumes/fs'
75
)
76
77
78
79
80
81
82
83
elastic = ElasticConfig(
    host='localhost',
    calc_index='calcs'
)
mongo = MongoConfig(
    host='localhost',
    users_db='users'
)
84
logstash = LogstashConfig(
Markus Scheidgen's avatar
Markus Scheidgen committed
85
    enabled=False,
86
87
    host=os.environ.get('NOMAD_LOGSTASH_HOST', 'localhost'),
    tcp_port=int(os.environ.get('NOMAD_LOGSTASH_TCPPORT', '5000'))
88
)