Пример #1
0
def test_src_windows_agent_has_correct_version(package_path, cmk_version):
    if not package_path.endswith(".tar.gz"):
        pytest.skip("%s is not a source package" %
                    os.path.basename(package_path))

    if is_daily_build_version(cmk_version):
        pytest.skip("Do not test daily builds")

    prefix = os.path.basename(package_path).replace(".tar.gz", "")
    for file_path in [
            prefix + "/agents/windows/check_mk_agent.exe",
            prefix + "/agents/windows/check_mk_agent-64.exe",
    ]:
        exe_bytes = subprocess.check_output(
            ["tar", "-xvOf", package_path, file_path])
        assert cmk_version.encode("ascii") in exe_bytes
Пример #2
0
def _render_agent_version_mismatch(
    agent_version: str,
    site_version: str,
    spec_type: str,
    spec: dict[str, str],
) -> str:
    if spec_type == "ignore":
        return ""

    if spec_type in ("specific", "site"):
        literal = spec.get("literal", site_version)
        return "" if literal == agent_version else f" (expected {literal})"

    # spec_type == "at_least"
    if is_daily_build_version(agent_version) and (
            at_least := spec.get("daily_build")) is not None:
        if int(agent_version.split("-")[-1].replace(".", "")) < int(
                at_least.replace(".", "")):
            return f" (expected at least {at_least})"
Пример #3
0
    if spec_type in ("specific", "site"):
        literal = spec.get("literal", site_version)
        return "" if literal == agent_version else f" (expected {literal})"

    # spec_type == "at_least"
    if is_daily_build_version(agent_version) and (
            at_least := spec.get("daily_build")) is not None:
        if int(agent_version.split("-")[-1].replace(".", "")) < int(
                at_least.replace(".", "")):
            return f" (expected at least {at_least})"

    if (at_least := spec.get("release")) is None:
        return ""

    return (f" (expected at least {at_least})"
            if is_daily_build_version(agent_version) or
            (parse_check_mk_version(agent_version) <
             parse_check_mk_version(at_least)) else "")


def _check_only_from(
    agent_only_from: Union[None, str, Sequence[str]],
    config_only_from: Union[None, str, list[str]],
    fail_state: State,
) -> CheckResult:
    if agent_only_from is None or config_only_from is None:
        return

    # do we really need 'normalize_ip_addresses'? It deals with '{' expansion.
    allowed_nets = set(normalize_ip_addresses(agent_only_from))
    expected_nets = set(normalize_ip_addresses(config_only_from))