config.py 2.34 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
28
29
CeleryConfig = namedtuple('Celery', [
    'rabbit_host', 'rabbit_port', 'rabbit_user', 'rabbit_password', 'redis_host'])
""" Used to configure the RabbitMQ and Redis backends for celery. """
30

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

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

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

40
files = FilesConfig(
41
42
    uploads_bucket='uploads',
    repository_bucket='repository',
43
44
    archive_bucket='archive',
    compress_archive=False
45
)
46
47
48
49
50
51
celery = CeleryConfig(
    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'),
52
53
)
minio = MinioConfig(
54
55
    host=os.environ.get('NOMAD_MINIO_HOST', 'localhost'),
    port=int(os.environ.get('NOMAD_MINIO_PORT', '9007')),
56
57
    accesskey='AKIAIOSFODNN7EXAMPLE',
    secret='wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
58
59
)
fs = FSConfig(
60
    tmp='.volumes/fs'
61
62
)
logstash = LogstashConfig(
Markus Scheidgen's avatar
Markus Scheidgen committed
63
    enabled=False,
64
65
    host=os.environ.get('NOMAD_LOGSTASH_HOST', 'localhost'),
    tcp_port=int(os.environ.get('NOMAD_LOGSTASH_TCPPORT', '5000'))
66
)