How to use the enoslib.api.expand_groups function in enoslib

To help you get started, we’ve selected a few enoslib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BeyondTheClouds / enos / enos / provider / g5k.py View on Github external
LOGGER.debug("Getting resources specific to the provider")
        return enoslib_conf

    # EnOS legacy mode
    LOGGER.debug("Getting generic resources from configuration")
    machines = []
    clusters = set()

    # get a plain configuration of resources
    resources = conf.get("resources", {})

    # when a topology configuration is present
    # replace resources with that configuration
    resources = conf.get("topology", resources)
    for desc in gen_enoslib_roles(resources):
        groups = expand_groups(desc["group"])
        for group in groups:
            clusters.add(desc["flavor"])
            machine = {"roles": [group, desc["role"]],
                       "nodes": desc["number"],
                       "cluster": desc["flavor"],
                       "primary_network": "int-net",
                       "secondary_networks": [],
                       # ensure at least one node
                       "min": 1}
            machines.append(machine)

    # check the location of the clusters
    sites = _get_sites(clusters)
    if len(sites) > 1:
        raise Exception("Multisite deployment isn't supported yet")
github BeyondTheClouds / enos / enos / provider / enos_vagrant.py View on Github external
def _build_enoslib_conf(config):
    conf = copy.deepcopy(config)
    enoslib_conf = conf.get("provider", {})
    enoslib_conf.pop("type", None)
    if enoslib_conf.get("resources") is not None:
        return enoslib_conf

    # This coould be common to everyone
    # Enoslib needs to be patched here
    resources = conf.get("topology", conf.get("resources", {}))
    machines = []
    for desc in gen_enoslib_roles(resources):
        # NOTE(msimonin): in the basic definition, we consider only
        # two networks
        grps = expand_groups(desc["group"])
        for grp in grps:
            machines.append({
                "flavour": desc["flavor"],
                "roles": [grp, desc["role"]],
                "number": desc["number"],
            })

    networks = [
        {"roles": ["network_interface"], "cidr": "192.168.42.0/24"},
        {"roles": ["neutron_external_interface"], "cidr": "192.168.43.0/24"}
    ]
    enoslib_conf.update({"resources": {"machines": machines,
                                       "networks": networks}})
    return enoslib_conf
github BeyondTheClouds / enos / enos / provider / static.py View on Github external
def _build_enoslib_conf(config):
    conf = copy.deepcopy(config)
    enoslib_conf = conf.get("provider")
    enoslib_conf.pop("type", None)
    if enoslib_conf.get("resources") is not None:
        return enoslib_conf

    # We fall here in the legacy mode but a bit modified
    # for the networks description
    networks = enoslib_conf["networks"]

    resources = conf.get("topology", conf.get("resources", {}))
    machines = []
    for desc in _gen_enoslib_roles(resources):

        grps = expand_groups(desc["group"])
        role = desc["role"]
        for grp in grps:
            machine = {
                "roles": [grp, role]
            }
            machine.update(desc)
            machines.append(machine)

    enoslib_conf = {
        "resources": {
            "machines": machines,
            "networks": networks
        }
    }

    return enoslib_conf
github BeyondTheClouds / enos / enos / provider / openstack.py View on Github external
def _build_enoslib_conf(conf):
    enoslib_conf = conf.get("provider", {})
    enoslib_conf.pop("type", None)
    if enoslib_conf.get("resources") is not None:
        return enoslib_conf

    resources = conf.get("topology", conf.get("resources", {}))
    machines = []
    for desc in gen_enoslib_roles(resources):
        grps = expand_groups(desc["group"])
        for grp in grps:
            machines.append({
                "flavour": desc["flavor"],
                "roles": [grp, desc["role"]],
                "number": desc["number"],
            })

    # Returning the enoslib description
    # Contribution are welcome for supporting more networks.
    enoslib_conf.update({"resources": {
        "machines": machines,
        "networks": [NETWORK_INTERFACE]}})
    return enoslib_conf