From 652830d26ac7da48b70dc3bf6a67de6443b864d3 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Sat, 24 Sep 2022 13:13:25 -0700 Subject: [PATCH] add fallback disable to data gateway --- data_gateway.py | 4 ++++ data_gateway_config.py | 1 + 2 files changed, 5 insertions(+) diff --git a/data_gateway.py b/data_gateway.py index 6a7fe15..0ba8e4f 100644 --- a/data_gateway.py +++ b/data_gateway.py @@ -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) ################################################################################################## diff --git a/data_gateway_config.py b/data_gateway_config.py index 8d5cff5..42bb73f 100644 --- a/data_gateway_config.py +++ b/data_gateway_config.py @@ -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'), })