Merge "Take all mounted config_volumes into account"

This commit is contained in:
Jenkins 2017-10-13 10:10:01 +00:00 committed by Gerrit Code Review
commit 466da79636

View File

@ -83,16 +83,12 @@ def pull_image(name):
log.debug(cmd_stderr) log.debug(cmd_stderr)
def match_config_volume(prefix, config): def match_config_volumes(prefix, config):
# Match the mounted config volume - we can't just use the # Match the mounted config volumes - we can't just use the
# key as e.g "novacomute" consumes config-data/nova # key as e.g "novacomute" consumes config-data/nova
volumes = config.get('volumes', []) volumes = config.get('volumes', [])
config_volume = None return sorted([os.path.dirname(v.split(":")[0]) for v in volumes if
for v in volumes: v.startswith(prefix)])
if v.startswith(prefix):
config_volume = os.path.dirname(v.split(":")[0])
break
return config_volume
def get_config_hash(config_volume): def get_config_hash(config_volume):
@ -374,14 +370,15 @@ for infile in infiles:
infile_data = json.load(f) infile_data = json.load(f)
for k, v in infile_data.iteritems(): for k, v in infile_data.iteritems():
config_volume = match_config_volume(config_volume_prefix, v) config_volumes = match_config_volumes(config_volume_prefix, v)
if config_volume: config_hashes = [get_config_hash(volume_path) for volume_path in config_volumes]
config_hash = get_config_hash(config_volume) config_hashes = filter(None, config_hashes)
if config_hash: config_hash = '-'.join(config_hashes)
env = v.get('environment', []) if config_hash:
env.append("TRIPLEO_CONFIG_HASH=%s" % config_hash) env = v.get('environment', [])
log.debug("Updating config hash for %s, config_volume=%s hash=%s" % (k, config_volume, config_hash)) env.append("TRIPLEO_CONFIG_HASH=%s" % config_hash)
infile_data[k]['environment'] = env log.debug("Updating config hash for %s, config_volume=%s hash=%s" % (k, config_volume, config_hash))
infile_data[k]['environment'] = env
outfile = os.path.join(os.path.dirname(infile), "hashed-" + os.path.basename(infile)) outfile = os.path.join(os.path.dirname(infile), "hashed-" + os.path.basename(infile))
with open(outfile, 'w') as out_f: with open(outfile, 'w') as out_f: