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
This commit is contained in:
parent
aadbbcbee0
commit
7622e53cc1
@ -43,13 +43,23 @@ def validate_config(config):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def copy_files(data):
|
def validate_source(data):
|
||||||
dest = data.get('dest')
|
|
||||||
source = data.get('source')
|
source = data.get('source')
|
||||||
|
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
LOG.error('The source to copy does not exist: {}'.format(source))
|
if data.get('optional'):
|
||||||
sys.exit(1)
|
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):
|
if os.path.exists(dest):
|
||||||
LOG.info('Removing existing destination: {}'.format(dest))
|
LOG.info('Removing existing destination: {}'.format(dest))
|
||||||
@ -149,8 +159,9 @@ def load_config():
|
|||||||
if 'config_files' in config:
|
if 'config_files' in config:
|
||||||
LOG.info('Copying service configuration files')
|
LOG.info('Copying service configuration files')
|
||||||
for data in config['config_files']:
|
for data in config['config_files']:
|
||||||
copy_files(data)
|
if validate_source(data):
|
||||||
set_permissions(data)
|
copy_files(data)
|
||||||
|
set_permissions(data)
|
||||||
else:
|
else:
|
||||||
LOG.debug('No files to copy found in config')
|
LOG.debug('No files to copy found in config')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user