diff --git a/common/container-puppet.py b/common/container-puppet.py index 02c0dcfc72..c52e5f1bf7 100755 --- a/common/container-puppet.py +++ b/common/container-puppet.py @@ -140,6 +140,21 @@ def pull_image(name): log.debug(cmd_stderr) +def get_config_base(prefix, volume): + # crawl the volume's path upwards until we find the + # volume's base, where the hashed config file resides + path = volume + base = prefix.rstrip(os.path.sep) + base_generated = os.path.join(base, 'puppet-generated') + while path.startswith(prefix): + dirname = os.path.dirname(path) + if dirname == base or dirname == base_generated: + return path + else: + path = dirname + raise ValueError("Could not find config's base for '%s'" % volume) + + def match_config_volumes(prefix, config): # Match the mounted config volumes - we can't just use the # key as e.g "novacomute" consumes config-data/nova @@ -148,8 +163,8 @@ def match_config_volumes(prefix, config): except AttributeError: log.error('Error fetching volumes. Prefix: %s - Config: %s' % (prefix, config)) raise - return sorted([os.path.dirname(v.split(":")[0]) for v in volumes if - v.startswith(prefix)]) + return sorted([get_config_base(prefix, v.split(":")[0]) + for v in volumes if v.startswith(prefix)]) def get_config_hash(config_volume):