How to use enoslib - 10 common examples

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 / task.py View on Github external
@enostask(new=True)
def up(config, config_file=None, env=None, **kwargs):
    logging.debug('phase[up]: args=%s' % kwargs)
    # Calls the provider and initialise resources

    provider_conf = config['provider']
    provider = make_provider(provider_conf)

    # Applying default configuration
    config = load_config(config,
                         provider.default_config())
    env['config'] = config
    env['config_file'] = config_file
    logging.debug("Loaded config: %s", config)

    rsc, networks = \
        provider.init(env['config'], kwargs['--force-deploy'])
github BeyondTheClouds / enos / enos / provider / g5k.py View on Github external
def init(self, config, force=False):
        LOGGER.debug("Building enoslib configuration")
        enoslib_conf = _build_enoslib_conf(config)
        conf = Configuration.from_dictionnary(enoslib_conf)
        LOGGER.debug("Creating G5K provider")
        g5k = provider.G5k(conf)
        LOGGER.info("Initializing G5K provider")
        roles, networks = g5k.init(force)
        _provision(roles)
        return roles, networks
github BeyondTheClouds / enos / enos / provider / g5k.py View on Github external
def init(self, config, force=False):
        LOGGER.debug("Building enoslib configuration")
        enoslib_conf = _build_enoslib_conf(config)
        conf = Configuration.from_dictionnary(enoslib_conf)
        LOGGER.debug("Creating G5K provider")
        g5k = provider.G5k(conf)
        LOGGER.info("Initializing G5K provider")
        roles, networks = g5k.init(force)
        _provision(roles)
        return roles, networks
github BeyondTheClouds / enos / enos / provider / enos_vagrant.py View on Github external
def init(self, conf, force_deploy=False):
        LOGGER.info("Vagrant provider")
        enoslib_conf = _build_enoslib_conf(conf)
        _conf = Configuration.from_dictionnary(enoslib_conf)
        vagrant = enoslib_vagrant.Enos_vagrant(_conf)
        roles, networks = vagrant.init(force_deploy)
        return roles, networks
github BeyondTheClouds / enos / enos / provider / chameleonbaremetal.py View on Github external
def init(self, conf, force_deploy=False):
        logging.info("Chameleon baremetal provider")
        enoslib_conf = self.build_config(conf)
        _conf = Configuration.from_dictionnary(enoslib_conf)
        ecb = Ecb(_conf)
        roles, networks = ecb.init(force_deploy=force_deploy)
        return roles, networks
github BeyondTheClouds / enos / enos / provider / chameleonbaremetal.py View on Github external
def init(self, conf, force_deploy=False):
        logging.info("Chameleon baremetal provider")
        enoslib_conf = self.build_config(conf)
        _conf = Configuration.from_dictionnary(enoslib_conf)
        ecb = Ecb(_conf)
        roles, networks = ecb.init(force_deploy=force_deploy)
        return roles, networks
github BeyondTheClouds / enos / enos / provider / chameleonkvm.py View on Github external
def init(self, conf, force_deploy=False):
        logging.info("Chameleonkvm provider")
        enoslib_conf = self.build_config(conf)
        _conf = Configuration.from_dictionnary(enoslib_conf)
        eckvm = Eckvm(_conf)
        roles, networks = eckvm.init(force_deploy=force_deploy)
        return roles, networks
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 / vmong5k.py View on Github external
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")
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