Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/api/server.py
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | def load_and_check_config(config_file, type='local'): | ||||
if not os.path.exists(config_file): | if not os.path.exists(config_file): | ||||
raise FileNotFoundError('Configuration file %s does not exist' % ( | raise FileNotFoundError('Configuration file %s does not exist' % ( | ||||
config_file, )) | config_file, )) | ||||
cfg = config.read(config_file) | cfg = config.read(config_file) | ||||
if 'storage' not in cfg: | if 'storage' not in cfg: | ||||
raise KeyError("Missing '%storage' configuration") | raise KeyError("Missing '%storage' configuration") | ||||
if type == 'local': | |||||
vcfg = cfg['storage'] | |||||
cls = vcfg.get('cls') | |||||
if cls != 'local': | |||||
raise ValueError( | |||||
"The storage backend can only be started with a 'local' " | |||||
"configuration") | |||||
args = vcfg['args'] | |||||
for key in ('db', 'objstorage'): | |||||
if not args.get(key): | |||||
raise ValueError( | |||||
"Invalid configuration; missing '%s' config entry" % key) | |||||
return cfg | return cfg | ||||
def make_app_from_configfile(): | def make_app_from_configfile(): | ||||
"""Run the WSGI app from the webserver, loading the configuration from | """Run the WSGI app from the webserver, loading the configuration from | ||||
a configuration file. | a configuration file. | ||||
SWH_CONFIG_FILENAME environment variable defines the | SWH_CONFIG_FILENAME environment variable defines the | ||||
Show All 15 Lines |