diff options
| author | Sam Yaple <sam@yaple.net> | 2015-09-27 10:33:18 +0000 |
|---|---|---|
| committer | Sam Yaple <sam@yaple.net> | 2015-09-28 10:35:52 +0000 |
| commit | 7622e53cc10b4871ebd3506bf590a58c1af76a9f (patch) | |
| tree | 64dc8a7b2bcf6687b09e705ae084691059a77ddd /docker | |
| parent | aadbbcbee0d19f60d7a8f6d3d04f61c1f1e48f30 (diff) | |
| download | kolla-7622e53cc10b4871ebd3506bf590a58c1af76a9f.tar.gz kolla-7622e53cc10b4871ebd3506bf590a58c1af76a9f.zip | |
Allow conf files to be optional
There are situations where we need to copy-if-exists mainly in cluster
setups. This is needed to replace config-external for ceph right now
Change-Id: I3c0898d8c584338a38e6ce4c4146e145910c5a52
Partially-Implements: blueprint replace-config-external
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/base/set_configs.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 7b5773550..19415c6fc 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -43,13 +43,23 @@ def validate_config(config): sys.exit(1) -def copy_files(data): - dest = data.get('dest') +def validate_source(data): source = data.get('source') if not os.path.exists(source): - LOG.error('The source to copy does not exist: {}'.format(source)) - sys.exit(1) + if data.get('optional'): + LOG.warn('{} does not exist, but is not required'.format(source)) + return False + else: + LOG.error('The source to copy does not exist: {}'.format(source)) + sys.exit(1) + + return True + + +def copy_files(data): + dest = data.get('dest') + source = data.get('source') if os.path.exists(dest): LOG.info('Removing existing destination: {}'.format(dest)) @@ -149,8 +159,9 @@ def load_config(): if 'config_files' in config: LOG.info('Copying service configuration files') for data in config['config_files']: - copy_files(data) - set_permissions(data) + if validate_source(data): + copy_files(data) + set_permissions(data) else: LOG.debug('No files to copy found in config') |
