Esempio n. 1
0
def download_agent(params):
    """Download agents shipped with Checkmk"""
    os_type: str = params.get("os_type")

    if os_type == "windows_msi":
        agent_path = agent.packed_agent_path_windows_msi()
    elif os_type == "linux_rpm":
        agent_path = agent.packed_agent_path_linux_rpm()
    elif os_type == "linux_deb":
        agent_path = agent.packed_agent_path_linux_deb()
    else:
        # This should never happen. Due to validation `os_type` can only be one
        # of the three elements above.
        raise AssertionError(
            f"Agent: os_type '{os_type}' not known in raw edition.")

    response = Response()
    response.headers["Content-Type"] = "application/octet-stream"
    response.headers[
        "Content-Disposition"] = f'attachment; filename="{agent_path.name}"'

    with open(agent_path, mode="rb") as f:
        response.data = f.read()
    response.status_code = 200
    return response
Esempio n. 2
0
def test_vanilla_agents_filenames(site, mocker):
    # we have functions to receive the path to the vanilla agent packages.
    # this test makes sure that those functions always point to existing files.

    # we have a mixed situation here: we use the source code from git, but
    # check against the installed site. so we have to make sure the version
    # matches: we mock the source code to reflect the site version.
    mocker.patch("cmk.gui.utils.agent.cmk_version", site.version.version)

    assert site.file_exists(str(agent.packed_agent_path_windows_msi()))
    assert site.file_exists(str(agent.packed_agent_path_linux_deb()))
    assert site.file_exists(str(agent.packed_agent_path_linux_rpm()))
Esempio n. 3
0
 def _packed_agents(self) -> List[str]:
     return [str(agent.packed_agent_path_linux_deb()), str(agent.packed_agent_path_linux_rpm())]