Exemple #1
0
def editions():
    yield ("cre", "CRESnapshotManager")

    if is_enterprise_repo():
        yield ("cee", "CRESnapshotManager")

    if is_managed_repo():
        yield ("cme", "CMESnapshotManager")
Exemple #2
0
def fake_version_and_paths():
    if is_running_as_site_user():
        return

    import _pytest.monkeypatch  # type: ignore # pylint: disable=import-outside-toplevel
    monkeypatch = _pytest.monkeypatch.MonkeyPatch()
    tmp_dir = tempfile.mkdtemp(prefix="pytest_cmk_")

    import cmk.utils.version as cmk_version  # pylint: disable=import-outside-toplevel
    import cmk.utils.paths  # pylint: disable=import-outside-toplevel

    if is_managed_repo():
        edition_short = "cme"
    elif is_enterprise_repo():
        edition_short = "cee"
    else:
        edition_short = "cre"

    monkeypatch.setattr(
        cmk_version, "omd_version", lambda: "%s.%s" %
        (cmk_version.__version__, edition_short))

    monkeypatch.setattr("cmk.utils.paths.agents_dir", "%s/agents" % cmk_path())
    monkeypatch.setattr("cmk.utils.paths.checks_dir", "%s/checks" % cmk_path())
    monkeypatch.setattr("cmk.utils.paths.notifications_dir",
                        Path(cmk_path()) / "notifications")
    monkeypatch.setattr("cmk.utils.paths.inventory_dir",
                        "%s/inventory" % cmk_path())
    monkeypatch.setattr("cmk.utils.paths.inventory_output_dir",
                        os.path.join(tmp_dir, "var/check_mk/inventory"))
    monkeypatch.setattr(
        "cmk.utils.paths.inventory_archive_dir",
        os.path.join(tmp_dir, "var/check_mk/inventory_archive"))
    monkeypatch.setattr("cmk.utils.paths.check_manpages_dir",
                        "%s/checkman" % cmk_path())
    monkeypatch.setattr("cmk.utils.paths.web_dir", "%s/web" % cmk_path())
    monkeypatch.setattr("cmk.utils.paths.omd_root", tmp_dir)
    monkeypatch.setattr("cmk.utils.paths.tmp_dir",
                        os.path.join(tmp_dir, "tmp/check_mk"))
    monkeypatch.setattr("cmk.utils.paths.counters_dir",
                        os.path.join(tmp_dir, "tmp/check_mk/counters"))
    monkeypatch.setattr("cmk.utils.paths.tcp_cache_dir",
                        os.path.join(tmp_dir, "tmp/check_mk/cache"))
    monkeypatch.setattr(
        "cmk.utils.paths.data_source_cache_dir",
        os.path.join(tmp_dir, "tmp/check_mk/data_source_cache"))
    monkeypatch.setattr("cmk.utils.paths.var_dir",
                        os.path.join(tmp_dir, "var/check_mk"))
    monkeypatch.setattr("cmk.utils.paths.log_dir",
                        os.path.join(tmp_dir, "var/log"))
    monkeypatch.setattr("cmk.utils.paths.autochecks_dir",
                        os.path.join(tmp_dir, "var/check_mk/autochecks"))
    monkeypatch.setattr(
        "cmk.utils.paths.precompiled_checks_dir",
        os.path.join(tmp_dir, "var/check_mk/precompiled_checks"))
    monkeypatch.setattr("cmk.utils.paths.crash_dir",
                        Path(cmk.utils.paths.var_dir) / "crashes")
    monkeypatch.setattr("cmk.utils.paths.include_cache_dir",
                        os.path.join(tmp_dir, "tmp/check_mk/check_includes"))
    monkeypatch.setattr("cmk.utils.paths.check_mk_config_dir",
                        os.path.join(tmp_dir, "etc/check_mk/conf.d"))
    monkeypatch.setattr("cmk.utils.paths.main_config_file",
                        os.path.join(tmp_dir, "etc/check_mk/main.mk"))
    monkeypatch.setattr("cmk.utils.paths.default_config_dir",
                        os.path.join(tmp_dir, "etc/check_mk"))
    monkeypatch.setattr("cmk.utils.paths.piggyback_dir",
                        Path(tmp_dir) / "var/check_mk/piggyback")
    monkeypatch.setattr("cmk.utils.paths.piggyback_source_dir",
                        Path(tmp_dir) / "var/check_mk/piggyback_sources")
    monkeypatch.setattr("cmk.utils.paths.htpasswd_file",
                        os.path.join(tmp_dir, "etc/htpasswd"))

    monkeypatch.setattr("cmk.utils.paths.local_share_dir",
                        Path(tmp_dir, "local/share/check_mk"))
    monkeypatch.setattr("cmk.utils.paths.local_checks_dir",
                        Path(tmp_dir, "local/share/check_mk/checks"))
    monkeypatch.setattr("cmk.utils.paths.local_notifications_dir",
                        Path(tmp_dir, "local/share/check_mk/notifications"))
    monkeypatch.setattr("cmk.utils.paths.local_inventory_dir",
                        Path(tmp_dir, "local/share/check_mk/inventory"))
    monkeypatch.setattr("cmk.utils.paths.local_check_manpages_dir",
                        Path(tmp_dir, "local/share/check_mk/checkman"))
    monkeypatch.setattr("cmk.utils.paths.local_agents_dir",
                        Path(tmp_dir, "local/share/check_mk/agents"))
    monkeypatch.setattr("cmk.utils.paths.local_web_dir",
                        Path(tmp_dir, "local/share/check_mk/web"))
    monkeypatch.setattr("cmk.utils.paths.local_pnp_templates_dir",
                        Path(tmp_dir, "local/share/check_mk/pnp-templates"))
    monkeypatch.setattr("cmk.utils.paths.local_doc_dir",
                        Path(tmp_dir, "local/share/doc/check_mk"))
    monkeypatch.setattr("cmk.utils.paths.local_locale_dir",
                        Path(tmp_dir, "local/share/check_mk/locale"))
    monkeypatch.setattr("cmk.utils.paths.local_bin_dir",
                        Path(tmp_dir, "local/bin"))
    monkeypatch.setattr("cmk.utils.paths.local_lib_dir",
                        Path(tmp_dir, "local/lib"))
    monkeypatch.setattr("cmk.utils.paths.local_mib_dir",
                        Path(tmp_dir, "local/share/snmp/mibs"))
    monkeypatch.setattr("cmk.utils.paths.diagnostics_dir",
                        Path(tmp_dir).joinpath("var/check_mk/diagnostics"))
    monkeypatch.setattr("cmk.utils.paths.site_config_dir",
                        Path(cmk.utils.paths.var_dir, "site_configs"))