Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _build_enoslib_configuration(configuration):
_configuration = copy.deepcopy(configuration)
enoslib_configuration = _configuration.get("provider", {})
enoslib_configuration.pop("type", None)
if "resources" in enoslib_configuration:
return enoslib_configuration
machines = []
clusters = set()
resources = _configuration.get("resources", {})
resources = _configuration.get("topology", resources)
for description in extra.gen_enoslib_roles(resources):
for group in api.expand_groups(description["group"]):
clusters.add(description["flavor"])
role = description["role"]
machine = {
"roles": [group, role],
"number": description["number"],
"cluster": description["flavor"],
# set default to 'medium' from enoslib FLAVOURS
"flavour": DEFAULT_FLAVOUR_BY_ROLE.get(role, 'medium')
}
machines.append(machine)
sites = g5k._get_sites(clusters)
if len(sites) > 1:
raise Exception("Multi-site deployment is not supported yet")
# FIXME: Find a neat way to put this into the next bootsrap_kolla
# playbook. Then, remove this util function and call directly the
# playbook from `enos os`.
globals_path = os.path.join(env['resultdir'], 'globals.yml')
globals_values = get_kolla_required_values(env)
globals_values.update(env['config']['kolla'])
globals_values.update(cwd=env['cwd'])
with open(globals_path, 'w') as f:
yaml.dump(globals_values, f, default_flow_style=False)
# Patch kolla-ansible sources + Write admin-openrc and
# password.yml in the result dir
enos_values = mk_enos_values(env)
playbook = os.path.join(ANSIBLE_DIR, 'bootstrap_kolla.yml')
api.run_ansible([playbook], env['inventory'], extra_vars=enos_values)