<commit_before>from ceph_deploy.util import pkg_managers, templates
from ceph_deploy.lib import remoto


def install(distro, version_kind, version, adjust_repos, **kw):
    packages = kw.get('components', ['ceph', 'ceph-mon', 'ceph-osd'])
    pkg_managers.yum_clean(distro.conn)
    pkg_managers.yum(distro.conn, packages)


def mirror_install(distro, repo_url,
                   gpg_url, adjust_repos, extra_installs=True, **kw):
    packages = kw.get('components', ['ceph', 'ceph-mon', 'ceph-osd'])
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present

    pkg_managers.yum_clean(distro.conn)

    if adjust_repos:
        remoto.process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url_path,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    if extra_installs:
        pkg_managers.yum(distro.conn, packages)


def repo_install(distro, reponame, baseurl, gpgkey, **kw):
    # do we have specific components to install?
    # removed them from `kw` so that we don't mess with other defauls
    packages = kw.pop('components', ['ceph', 'ceph-mon', 'ceph-osd'])

    # Get some defaults
    name = kw.pop('name', '%s repo' % reponame)
    enabled = kw.pop('enabled', 1)
    gpgcheck = kw.pop('gpgcheck', 1)
    install_ceph = kw.pop('install_ceph', False)
    proxy = kw.pop('proxy', '') # will get ignored if empty
    _type = 'repo-md'
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    pkg_managers.yum_clean(distro.conn)

    if gpgkey:
        remoto.process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpgkey,
            ]
        )

    repo_content = templates.custom_repo(
        reponame=reponame,
        name=name,
        baseurl=baseurl,
        enabled=enabled,
        gpgcheck=gpgcheck,
        _type=_type,
        gpgkey=gpgkey,
        proxy=proxy,
        **kw
    )

    distro.conn.remote_module.write_yum_repo(
        repo_content,
        "%s.repo" % reponame
    )

    # Some custom repos do not need to install ceph
    if install_ceph:
        pkg_managers.yum(distro.conn, packages)
<commit_msg>use default fallback components in rhel<commit_after>from ceph_deploy.util import pkg_managers, templates
from ceph_deploy.lib import remoto
from ceph_deploy.util.constants import default_components


def install(distro, version_kind, version, adjust_repos, **kw):
    packages = kw.get('components', default_components) or default_components
    pkg_managers.yum_clean(distro.conn)
    pkg_managers.yum(distro.conn, packages)


def mirror_install(distro, repo_url,
                   gpg_url, adjust_repos, extra_installs=True, **kw):
    packages = kw.get('components', default_components) or default_components
    repo_url = repo_url.strip('/')  # Remove trailing slashes
    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present

    pkg_managers.yum_clean(distro.conn)

    if adjust_repos:
        remoto.process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpg_url_path,
            ]
        )

        ceph_repo_content = templates.ceph_repo.format(
            repo_url=repo_url,
            gpg_url=gpg_url
        )

        distro.conn.remote_module.write_yum_repo(ceph_repo_content)

    if extra_installs:
        pkg_managers.yum(distro.conn, packages)


def repo_install(distro, reponame, baseurl, gpgkey, **kw):
    # do we have specific components to install?
    # removed them from `kw` so that we don't mess with other defauls
    packages = kw.pop('components', default_components) or default_components

    # Get some defaults
    name = kw.pop('name', '%s repo' % reponame)
    enabled = kw.pop('enabled', 1)
    gpgcheck = kw.pop('gpgcheck', 1)
    install_ceph = kw.pop('install_ceph', False)
    proxy = kw.pop('proxy', '') # will get ignored if empty
    _type = 'repo-md'
    baseurl = baseurl.strip('/')  # Remove trailing slashes

    pkg_managers.yum_clean(distro.conn)

    if gpgkey:
        remoto.process.run(
            distro.conn,
            [
                'rpm',
                '--import',
                gpgkey,
            ]
        )

    repo_content = templates.custom_repo(
        reponame=reponame,
        name=name,
        baseurl=baseurl,
        enabled=enabled,
        gpgcheck=gpgcheck,
        _type=_type,
        gpgkey=gpgkey,
        proxy=proxy,
        **kw
    )

    distro.conn.remote_module.write_yum_repo(
        repo_content,
        "%s.repo" % reponame
    )

    # Some custom repos do not need to install ceph
    if install_ceph:
        pkg_managers.yum(distro.conn, packages)

{'fraction_non_alphanumeric': 0.10798875953432356, 'fraction_numerical': 0.0012043356081894822, 'mean_word_length': 2.2912813738441216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2993716', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1613, 'n_words': 329}