config.py 3.1 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

Markus Scheidgen's avatar
Markus Scheidgen committed
45
46
47
NomadServicesConfig = namedtupe('NomadServicesConfig', ['api_base_path'])
""" Used to configure nomad services: worker, handler, api """

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

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

64
celery = CeleryConfig(
65
    broker_url=rabbit_url,
66
67
    backend_url=redis_url,
    serializer='pickle'
68
)
69

70
minio = MinioConfig(
71
72
    host=os.environ.get('NOMAD_MINIO_HOST', 'localhost'),
    port=int(os.environ.get('NOMAD_MINIO_PORT', '9007')),
73
74
    accesskey='AKIAIOSFODNN7EXAMPLE',
    secret='wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
75
76
)
fs = FSConfig(
77
    tmp='.volumes/fs'
78
)
79
elastic = ElasticConfig(
80
    host=os.environ.get('NOMAD_ELASTIC_HOST', 'localhost'),
81
82
83
    calc_index='calcs'
)
mongo = MongoConfig(
84
    host=os.environ.get('NOMAD_MONGO_HOST', 'localhost'),
85
86
    users_db='users'
)
87
logstash = LogstashConfig(
88
    enabled=True,
89
90
    host=os.environ.get('NOMAD_LOGSTASH_HOST', 'localhost'),
    tcp_port=int(os.environ.get('NOMAD_LOGSTASH_TCPPORT', '5000'))
91
)
Markus Scheidgen's avatar
Markus Scheidgen committed
92
93
94
services = NomadServicesConfig(
    api_base_path='/nomadxt/api'
)