add fallback disable to data gateway

This commit is contained in:
KF7EEL 2022-09-24 13:13:25 -07:00
parent 391e76d72c
commit 652830d26a
2 changed files with 5 additions and 0 deletions

View File

@ -575,6 +575,7 @@ def download_config(CONFIG_FILE, cli_file):
corrected_config['WEB_SERVICE'] = {}
corrected_config['WEB_SERVICE']['THIS_SERVER_NAME'] = CONFIG_FILE['WEB_SERVICE']['THIS_SERVER_NAME']
corrected_config['WEB_SERVICE']['URL'] = CONFIG_FILE['WEB_SERVICE']['URL']
corrected_config['WEB_SERVICE']['DISABLE_FALLBACK'] = CONFIG_FILE['WEB_SERVICE']['DISABLE_FALLBACK']
corrected_config['WEB_SERVICE']['SHARED_SECRET'] = CONFIG_FILE['WEB_SERVICE']['SHARED_SECRET']
corrected_config['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] = CONFIG_FILE['WEB_SERVICE']['REMOTE_CONFIG_ENABLED']
corrected_config['WEB_SERVICE'].update(resp['config']['WEB_SERVICE'])
@ -733,6 +734,9 @@ def download_config(CONFIG_FILE, cli_file):
# For exception, write blank dict
except requests.ConnectionError:
logger.error('Config server unreachable, defaulting to local config')
if LOCAL_CONFIG['WEB_SERVICE']['DISABLE_FALLBACK']:
logger.error('Falback disabled. Exiting...')
sys.exit()
return data_gateway_config.build_config(cli_file)
##################################################################################################

View File

@ -162,6 +162,7 @@ def build_config(_config_file):
'THIS_SERVER_NAME': config.get(section, 'THIS_SERVER_NAME'),
'URL': config.get(section, 'URL'),
'REMOTE_CONFIG_ENABLED': config.getboolean(section, 'REMOTE_CONFIG_ENABLED'),
'DISABLE_FALLBACK': config.getboolean(section, 'DISABLE_FALLBACK'),
'DASHBOARD_ONLY': config.getboolean(section, 'DASHBOARD_ONLY'),
'SHARED_SECRET': config.get(section, 'SHARED_SECRET'),
})