How to use the jumbo.utils.checks 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
@checks.valid_cluster
def delete_cluster(*, cluster):
    """Delete a cluster.

    :param name: Cluster name
    :type name: str
    :raises ex.LoadError: If the cluster doesn't exist
    :return: True if the deletion was successfull
    """
    try:
        # Vagrant destroy
        current_dir = os.getcwd()
        os.chdir(JUMBODIR + cluster + '/')
        subprocess.check_output(['vagrant', 'destroy', '-f'])
        os.chdir(current_dir)
        rmtree(JUMBODIR + cluster)
    except IOError as e:
github adaltas / jumbo / jumbo / cli / main.py View on Github external
sh.add_command(addcomponent)
    sh.add_command(listcomponents)
    sh.add_command(rmservice)
    sh.add_command(rmcomponent)
    sh.add_command(checkservice)
    sh.add_command(listservices)
    sh.add_command(start)
    sh.add_command(stop)
    sh.add_command(status)
    sh.add_command(provision)
    sh.add_command(restart)

    # If cluster exists, call manage command (saves the shell in session
    #  variable svars and adapts the shell prompt)
    if cluster:
        if not checks.check_cluster(cluster):
            click.echo('This cluster does not exist.'
                       ' Use "create NAME" to create it.', err=True)
        else:
            ctx.invoke(use, name=cluster)

    # Run the command, or the shell if no command is passed
    sh.invoke(ctx)
github adaltas / jumbo / jumbo / utils / session.py View on Github external
def load_config(cluster):
    """Load a cluster in the session.

    :param cluster: Cluster name
    :type cluster: str
    :return: True on success
    """
    global svars

    if not checks.check_cluster(cluster):
        raise ex.LoadError('cluster', cluster, 'NotExist')

    if not clusters.check_config(cluster):
        raise ex.LoadError('cluster', cluster, 'NoConfFile')
    else:
        try:
            with open(JUMBODIR + cluster + '/jumbo_config', 'r') as jc:
                svars = json.load(jc)
        except IOError as e:
            raise ex.LoadError('cluster', cluster, e.strerror)

    vs.update_versions_file()

    return True
github adaltas / jumbo / jumbo / core / clusters.py View on Github external
def create_cluster(domain, template=None, *, cluster):
    """Create a new cluster and load it in the session.

    :param name: New cluster name
    :type name: str
    :param domain: New cluster domain name
    :type domain: str
    :raises ex.CreationError: If name already used
    :return: True on creation success
    """

    if checks.check_cluster(cluster):
        raise ex.CreationError('cluster', cluster, 'name', cluster, 'Exists')

    allowed_chars = string.ascii_letters + string.digits + '-'
    for l in cluster:
        if l not in allowed_chars:
            raise ex.CreationError('cluster', cluster, 'name',
                                   'Allowed characters: ' + allowed_chars,
                                   'NameNotAllowed')

    ss.clear()
    data_dir = os.path.dirname(os.path.abspath(__file__)) + '/data/'
    config_dir = os.path.dirname(os.path.abspath(__file__)) + '/config/'
    if template:
        try:
            with open(config_dir + 'templates/' + template + '.json') \
                    as template_file: