How to use the jumbo.utils.settings.JUMBODIR 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 / bundles.py View on Github external
def list_bundles():
    """List bundles of the current cluster and available bundles"""

    path_list = [f.path.split('/')[-1]
                 for f in os.scandir(JUMBODIR+'bundles') if f.is_dir()]
    return (ss.svars.get('bundles', []), path_list)
github adaltas / jumbo / jumbo / utils / prepare.py View on Github external
def init_jumbo():
    if not os.path.isfile(JUMBODIR + 'versions.json'):
        if not os.path.isdir(JUMBODIR):
            pathlib.Path(JUMBODIR).mkdir()
        copyfile(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +
                 '/core/config/versions.json', JUMBODIR + 'versions.json')

    if not os.path.isdir(JUMBODIR + 'clusters/'):
        pathlib.Path(JUMBODIR + 'clusters').mkdir()

    if not os.path.isfile(JUMBODIR + 'bundles/jumbo-services/'):
        if not os.path.isdir(JUMBODIR + 'bundles/'):
            pathlib.Path(JUMBODIR + 'bundles').mkdir()
        dir_util.copy_tree(os.path.dirname(os.path.dirname(
            os.path.abspath(__file__))) +
            '/core/data/jumbo-services',
            JUMBODIR + 'bundles/jumbo-services')
github adaltas / jumbo / jumbo / core / vault.py View on Github external
def add_pass(vault_key, vault_value, length, password, *, cluster):
    """Add entry in cluster vault"""
    vault_file = JUMBODIR + 'clusters/' + cluster + '/inventory/group_vars/all/vault'
    vault = Vault(password)
    data = {}

    if os.path.isfile(vault_file):
        data = vault.load(open(vault_file).read())

    if vault_value is None:
        print('Generating random password')
        vault_value = ''.join(random.choice(
            string.ascii_letters + string.digits) for _ in range(length))

    create_keys(data, vault_key, vault_value)
    print(yaml.dump(data, default_flow_style=False))
    vault.dump(data, open(vault_file, 'wb'))
github adaltas / jumbo / jumbo / utils / checks.py View on Github external
def check_cluster(name):
    """Return true if the cluster exists.

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

    return os.path.isdir(JUMBODIR + name)
github adaltas / jumbo / jumbo / utils / versions.py View on Github external
:raises ex.LoadError: If the file versions.json doesn't exist
    :return: The versions to use
    :rtype: dict
    """

    yaml_versions = {
        'services': {},
        'platform': {}
    }

    if not os.path.isfile(JUMBODIR + 'versions.json'):
        raise ex.LoadError('file', JUMBODIR + 'versions.json', 'NotExist')

    # Global versions settings
    with open(JUMBODIR + 'versions.json', 'r') as vs:
        jumbo_versions = json.load(vs)

    yaml_versions = update_yaml_versions(yaml_versions, jumbo_versions)

    if not cluster:
        return yaml_versions

    # Cluster versions settings
    if os.path.isfile(JUMBODIR + cluster + '/versions.json'):
        with open(
                JUMBODIR + cluster + '/versions.json', 'r') as vs:
            cluster_versions = json.load(vs)

        yaml_versions = update_yaml_versions(yaml_versions, cluster_versions)

    return yaml_versions
github adaltas / jumbo / jumbo / utils / vagrant.py View on Github external
def handle_cmd(cmd, *, cluster):
    try:
        res = subprocess.Popen(cmd,
                               cwd=os.path.join(JUMBODIR+'clusters/', cluster),
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT
                               )

        for line in res.stdout:
            print(line.decode('utf-8').rstrip())

    except KeyboardInterrupt:
        res.kill()
github adaltas / jumbo / jumbo / utils / prepare.py View on Github external
def init_jumbo():
    if not os.path.isfile(JUMBODIR + 'versions.json'):
        if not os.path.isdir(JUMBODIR):
            pathlib.Path(JUMBODIR).mkdir()
        copyfile(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +
                 '/core/config/versions.json', JUMBODIR + 'versions.json')

    if not os.path.isdir(JUMBODIR + 'clusters/'):
        pathlib.Path(JUMBODIR + 'clusters').mkdir()

    if not os.path.isfile(JUMBODIR + 'bundles/jumbo-services/'):
        if not os.path.isdir(JUMBODIR + 'bundles/'):
            pathlib.Path(JUMBODIR + 'bundles').mkdir()
        dir_util.copy_tree(os.path.dirname(os.path.dirname(
            os.path.abspath(__file__))) +
            '/core/data/jumbo-services',
            JUMBODIR + 'bundles/jumbo-services')

    if not os.path.isdir(JUMBODIR + 'templates/'):
github adaltas / jumbo / jumbo / core / services.py View on Github external
: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

    return m_conf['components']
github adaltas / jumbo / jumbo / core / clusters.py View on Github external
def check_config(name):
    """Return true if the cluster has a 'jumbo_config' file.

    :param name: Cluster name
    :type name: str
    """
    return os.path.isfile(JUMBODIR + name + '/jumbo_config')
github adaltas / jumbo / jumbo / utils / session.py View on Github external
pool_name=POOLNAME))

        hosts_temp = jinja_env.get_template('hosts.j2')
        with open(JUMBODIR + svars['cluster'] + '/playbooks/inventory/hosts',
                  'w') as vf:
            vf.write(hosts_temp.render(hosts=svars['nodes']))

        with open(JUMBODIR + svars['cluster'] +
                  '/playbooks/inventory/group_vars/all', 'w') as gva:
            yaml.dump(generate_ansible_vars(), gva, default_flow_style=False,
                      explicit_start=True)

        if services_components_hosts:
            clear_bp()
            generate_blueprint(services_components_hosts)
            with open(JUMBODIR + svars['cluster'] +
                      '/playbooks/roles/postblueprint/files/blueprint.json',
                      'w') as bpf:
                json.dump(bp, bpf)
            with open(JUMBODIR + svars['cluster'] +
                      '/playbooks/roles/postblueprint/files/cluster.json',
                      'w') as clf:
                json.dump(generate_cluster(), clf)

        if 'KERBEROS' in svars['services']:
            with open(JUMBODIR + svars['cluster'] +
                      '/playbooks/roles/kerberos-part1/files/krb5-conf.json',
                      'w') as krbf:
                json.dump(generate_krb5_conf(), krbf)

    except IOError:
        return False