Return nice message when etcd section is missing
This commit is contained in:
parent
ba515f0b48
commit
808271f3e0
2 changed files with 6 additions and 5 deletions
|
@ -1,5 +1,3 @@
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ucloud.settings import settings
|
from ucloud.settings import settings
|
||||||
|
|
|
@ -30,7 +30,10 @@ class Settings(object):
|
||||||
self.config_key = config_key
|
self.config_key = config_key
|
||||||
|
|
||||||
self.read_internal_values()
|
self.read_internal_values()
|
||||||
self.config_parser.read(self.config_file)
|
try:
|
||||||
|
self.config_parser.read(self.config_file)
|
||||||
|
except Exception as err:
|
||||||
|
logger.error('%s', err)
|
||||||
|
|
||||||
def get_etcd_client(self):
|
def get_etcd_client(self):
|
||||||
args = tuple()
|
args = tuple()
|
||||||
|
@ -39,8 +42,8 @@ class Settings(object):
|
||||||
'host': self.config_parser.get('etcd', 'url'),
|
'host': self.config_parser.get('etcd', 'url'),
|
||||||
'port': self.config_parser.get('etcd', 'port'),
|
'port': self.config_parser.get('etcd', 'port'),
|
||||||
'ca_cert': self.config_parser.get('etcd', 'ca_cert'),
|
'ca_cert': self.config_parser.get('etcd', 'ca_cert'),
|
||||||
'cert_cert': self.config_parser.get('etcd','cert_cert'),
|
'cert_cert': self.config_parser.get('etcd', 'cert_cert'),
|
||||||
'cert_key': self.config_parser.get('etcd','cert_key')
|
'cert_key': self.config_parser.get('etcd', 'cert_key')
|
||||||
}
|
}
|
||||||
except configparser.Error as err:
|
except configparser.Error as err:
|
||||||
raise configparser.Error('{} in config file {}'.format(err.message, self.config_file)) from err
|
raise configparser.Error('{} in config file {}'.format(err.message, self.config_file)) from err
|
||||||
|
|
Loading…
Reference in a new issue