How to use the jumbo.core.nodes 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 / cli / main.py View on Github external
def addnode(ctx, name, types, ip, ram, cpus, cluster):
    """
    Create a new VM in the cluster being managed.
    Another cluster can be specified with "--cluster".

    :param name: New VM name
    """
    switched = True if cluster else False
    if not cluster:
        cluster = ss.svars['cluster']

    try:
        nodes.add_node(name, ip, ram, types, cpus, cluster=cluster)
        count = services.auto_install_node(name, cluster)
    except (ex.LoadError, ex.CreationError) as e:
        print_with_color(e.message, 'red')
        if e.type == 'NoConfFile':
            click.echo('Use "repair" to regenerate `jumbo_config`.')
        switched = False
    else:
        click.echo('Machine "{}" added to cluster "{}". {}'
                   .format(name, cluster,
                           '{} clients auto installed on "{}".'
                           .format(count, name) if count else ''))
    finally:
        if switched:
            set_context(ctx, cluster)
github adaltas / jumbo / jumbo / core / services.py View on Github external
def remove_component(component, *, node, cluster):
    """Remove a service of a specified node in a specified cluster.

    :param name: Service name
    :type name: str
    :param node: Machine name
    :type node: str
    :param cluster: Cluster name
    :type cluster: str
    :raises ex.LoadError: [description]
    :raises ex.CreationError: [description]
    """

    ss.load_config(cluster)

    if not nodes.check_node(cluster=cluster, node=node):
        raise ex.LoadError('node', node, 'NotExist')

    service = check_component(component)
    if not service:
        raise ex.LoadError('component', component, 'NotExist')

    for i, m in enumerate(ss.svars['nodes']):
        if m['name'] == node:
            m_index = i

    if component not in ss.svars['nodes'][m_index]['components']:
        raise ex.CreationError('node', node, 'component', component,
                               'NotInstalled')

    ss.svars['nodes'][m_index]['components'].remove(component)
    ss.dump_config(get_services_components_hosts())
github adaltas / jumbo / jumbo / cli / main.py View on Github external
"""Removes a VM.

    :param name: VM name
    """
    switched = True if cluster else False
    if not cluster:
        cluster = ss.svars['cluster']

    if not force:
        if not click.confirm(
                'Are you sure you want to remove the node "{}" '
                'of cluster "{}"?'.format(name, cluster)):
            return

    try:
        nodes.remove_node(cluster=cluster, node=name)
    except ex.LoadError as e:
        print_with_color(e.message, 'red')
        if e.type == 'NoConfFile':
            click.echo('Use "repair" to regenerate `jumbo_config`')
        switched = False
    else:
        click.echo('Machine "{}" removed of cluster "{}".'
                   .format(name, cluster))
    finally:
        if switched:
            set_context(ctx, cluster)
github adaltas / jumbo / jumbo / core / services.py View on Github external
def list_components(*, node, cluster):
    """List the components installed on a node of a specified cluster.

    :param node: Machine name
    :type node: str
    :param cluster: Cluster name
    :type cluster: str
    :raises ex.LoadError: [description]
    :return: The list of the components installed on the node
    :rtype: list
    """

    if not nodes.check_node(cluster=cluster, node=node):
        raise ex.LoadError('node', node, 'NotExist')

    if cluster != ss.svars['cluster']:
        try:
            with open(JUMBODIR + cluster + '/jumbo_config', 'r') as clf:
                cluster_conf = json.load(clf)
        except IOError as e:
            raise ex.LoadError('cluster', cluster, e.strerror)
    else:
        cluster_conf = ss.svars

    for m in cluster_conf['nodes']:
        if m['name'] == node:
            m_conf = m
            break