How to use the jumbo.utils.session.clear 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
:param name: Name of the cluster to delete
    """

    if not force:
        if not click.confirm(
                'Are you sure you want to delete the cluster %s' % name):
            return

    try:
        clusters.delete_cluster(cluster=name)
    except ex.LoadError as e:
        print_with_color(e.message, 'red')
    else:
        click.echo('Cluster "%s" deleted.' % name)
        ss.clear()
        ctx.meta['jumbo_shell'].prompt = click.style('jumbo > ', fg='green')
github adaltas / jumbo / jumbo / core / clusters.py View on Github external
def repair_cluster(domain, *, cluster):
    """Recreate the cluster 'jumbo_config' file if it doesn't exist.

    :param name: Cluster name
    :type name: str
    :param domain: Cluster domaine name
    :type domain: str
    :return: True if the 'jumbo_config' has been recreated
    """
    if not check_config(cluster):
        ss.clear()
        ss.svars['cluster'] = cluster
        ss.svars['domain'] = domain if domain else '%s.local' % cluster
        ss.dump_config()
        return True

    return False
github adaltas / jumbo / jumbo / core / clusters.py View on Github external
: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:
        raise ex.LoadError('cluster', cluster, e.strerror)

    ss.clear()
    return True
github adaltas / jumbo / jumbo / core / clusters.py View on Github external
: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:
                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