diff options
| author | Angus Salkeld <asalkeld@mirantis.com> | 2015-11-10 13:10:11 +1000 |
|---|---|---|
| committer | Michal Rostecki <mrostecki@mirantis.com> | 2015-11-17 07:51:32 +0000 |
| commit | 2f1c00a467e381b690b8fd38a5c3b003f2da7ecf (patch) | |
| tree | e70adf7d793dfc1333e8e24911c2812668e7599e /docker/base | |
| parent | df0ef8ddb504fef0eddffd09127e1bb98a3fca88 (diff) | |
| download | kolla-2f1c00a467e381b690b8fd38a5c3b003f2da7ecf.tar.gz kolla-2f1c00a467e381b690b8fd38a5c3b003f2da7ecf.zip | |
Add support for loading kolla config from ENV
Implements: blueprint zookeeper
Change-Id: Ibabcb5d6d304be9290633338c513f16651d4479a
Diffstat (limited to 'docker/base')
| -rw-r--r-- | docker/base/set_configs.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 12da192c0..cd9ccd83f 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -140,21 +140,38 @@ def set_permissions(data): def load_config(): - config_file = '/var/lib/kolla/config_files/config.json' - LOG.info('Loading config file at {}'.format(config_file)) + def load_from_env(): + config_raw = os.environ.get("KOLLA_CONFIG") + if config_raw is None: + return None - # Attempt to read config file - with open(config_file) as f: + # Attempt to read config try: - config = json.load(f) + return json.loads(config_raw) except ValueError: - LOG.error('Invalid json file found at {}'.format(config_file)) - sys.exit(1) - except IOError as e: - LOG.error('Could not read file {}. Failed with error {}'.format( - config_file, e)) + LOG.error('Invalid json for Kolla config') sys.exit(1) + def load_from_file(): + config_file = '/var/lib/kolla/config_files/config.json' + LOG.info('Loading config file at {}'.format(config_file)) + + # Attempt to read config file + with open(config_file) as f: + try: + return json.load(f) + except ValueError: + LOG.error('Invalid json file found at {}'.format(config_file)) + sys.exit(1) + except IOError as e: + LOG.error('Could not read file {}. Failed with error {}' + .format(config_file, e)) + sys.exit(1) + + config = load_from_env() + if config is None: + config = load_from_file() + LOG.info('Validating config file') validate_config(config) |
