uncloud/config.py

29 lines
810 B
Python
Raw Normal View History

2020-01-20 07:30:12 +00:00
import configparser
import sys
import os
2020-01-20 07:30:12 +00:00
from etcd_wrapper import EtcdWrapper
2020-01-27 08:40:57 +00:00
from ldap_manager import LdapManager
2020-01-20 07:30:12 +00:00
config_file = os.environ.get('meow-pay-config-file', default='pay.conf')
2020-01-20 07:30:12 +00:00
config = configparser.ConfigParser()
try:
successfully_read_files = config.read(config_file)
except configparser.Error as err:
sys.exit(err)
if not successfully_read_files:
sys.exit(f'Config file {config_file} couldn\'t be read.')
try:
etcd_client = EtcdWrapper(host=config.get('etcd', 'host'), port=config.get('etcd', 'port'))
2020-01-27 08:40:57 +00:00
ldap_manager = LdapManager(
server=config.get('ldap', 'server'), admin_dn=config.get('ldap', 'admin_dn'),
admin_password=config.get('ldap', 'admin_password')
)
except configparser.Error as err:
sys.exit(f'{err} in config file {config_file}.')