elements = []
# Add prefix.
if prefix != '':
elements.append(prefix)
has_prefix = True
else:
has_prefix = False
# Add osystem
elements.append(osystem)
# Add architecture/sub-architecture.
if node is not None:
arch = split_subarch(node.architecture)
elements.extend(arch)
# Add release.
elements.append(release)
# Add hostname.
if node is not None:
elements.append(node.hostname)
while elements:
yield compose_filename(elements)
# Backward-compatibility fix for 1439366: also generate a filename
# with the 'osystem' omitted when deploying with Ubuntu.
if osystem == UBUNTU_NAME:
should_emit = (
(not has_prefix and len(elements) > 1) or
(has_prefix and len(elements) > 2))
if should_emit:
cutoff = 1 if has_prefix else 0
yield compose_filename(
elements[:cutoff] + elements[cutoff + 1:])
elements.pop()
if default:
yield GENERIC_FILENAME