How to use the jumbo.core.services function in jumbo

To help you get started, we’ve selected a few jumbo 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 adaltas / jumbo / jumbo / core / clusters.py View on Github external
with open(config_dir + 'templates/' + template + '.json') \
                    as template_file:
                ss.svars = json.load(template_file)
        except:
            raise ex.LoadError('template', template, 'NotExist')

    pathlib.Path(JUMBODIR + cluster).mkdir(parents=True)

    dir_util.copy_tree(data_dir, JUMBODIR + cluster)
    dir_util._path_created = {}
    ss.svars['cluster'] = cluster
    ss.svars['domain'] = domain if domain else '%s.local' % cluster

    services_components_hosts = None
    if template:
        services_components_hosts = services.get_services_components_hosts()

    ss.dump_config(services_components_hosts)
    return True
github adaltas / jumbo / jumbo / cli / main.py View on Github external
def use(ctx, name):
    """Set a cluster to manage. Persist --cluster option.

    :param name: Cluster name
    """

    click.echo('Loading %s...' % name)

    try:
        ss.load_config(cluster=name)
        ss.dump_config(services.get_services_components_hosts())
    except ex.LoadError as e:
        print_with_color(e.message, 'red')
        if e.type == 'NoConfFile':
            click.echo('Use "repair" to regenerate `jumbo_config`.')
    else:
        click.echo('Cluster "%s" loaded.' % name)
        set_context(ctx, name)
github adaltas / jumbo / jumbo / core / bundles.py View on Github external
def rm_bundle(*, name, cluster):
    """Remove bundle from the current cluster"""

    (active, available) = list_bundles()
    if name not in available:
        raise RuntimeError('Bundle `%s` does not exist.' % name)

    if name in active:
        index = active.index(name)
        ss.svars['bundles'].remove(name)
        services.config = services.load_services_conf(cluster=cluster)

        available_serv = []
        for serv in services.config['services']:
            available_serv.append(serv['name'])

        for serv in ss.svars['services']:
            if serv not in available_serv:
                active.insert(index, name)
                services.config = services.load_services_conf(cluster=cluster)
                raise RuntimeError('Cannot remove bundle `%s`. '
                                   'Service `%s` belongs to this bundle '
                                   'and is present on the cluster.'
                                   % (name, serv))

        ss.dump_config(services.get_services_components_hosts(),
                       services.config)
    else:
        raise Warning('Bundle `%s` is not active.' % name)
github adaltas / jumbo / jumbo / cli / main.py View on Github external
def listservices(cluster):
    """Check the state of all services installed.

    :param cluster: Cluster name
    :type cluster: str
    """

    if not cluster:
        cluster = ss.svars['cluster']

    try:
        table_serv = PrettyTable(['Service', 'HA', 'Missing components'])
        table_serv.align = 'l'
        for s in ss.svars['services']:
            color = 'green'
            missing_comp = services.check_service_complete(name=s,
                                                           cluster=cluster)
            if missing_comp:
                print_missing = '\n'.join(missing_comp)
                color = 'yellow' if len(missing_comp) < 5 else 'red'
            else:
                print_missing = '-'
            table_serv.add_row([click.style(s, fg=color),
                                'X' if services.check_ha(s) else ' ',
                                print_missing])
        table_serv.sortby = 'Service'
    except (ex.LoadError, ex.CreationError) as e:
        print_with_color(e.message, 'red')
    else:
        click.echo(table_serv)