예제 #1
0
def package_install(args):
    # type: (List[str]) -> None
    if len(args) != 1:
        raise PackageException("Usage: check_mk -P install NAME")
    path = Path(args[0])
    if not path.exists():
        raise PackageException("No such file %s." % path)

    install_package_by_path(path)
예제 #2
0
def package_install(args):
    if len(args) != 1:
        raise PackageException("Usage: check_mk -P install NAME")
    path = Path(args[0])
    if not path.exists():
        raise PackageException("No such file %s." % path)

    return install_package_by_path(path)
예제 #3
0
def test_install_package_by_path(tmp_path):
    # Create
    _create_simple_test_package("aaa")
    package_info = packaging.read_package_info("aaa")

    # Write MKP file
    mkp_path = tmp_path.joinpath("aaa.mkp")
    with mkp_path.open("wb") as mkp:
        packaging.create_mkp_file(package_info, mkp)

    # Remove files from local hierarchy
    packaging.remove_package(package_info)
    assert packaging._package_exists("aaa") is False

    # And now install the package from memory
    packaging.install_package_by_path(mkp_path)

    # Check result
    assert packaging._package_exists("aaa") is True
    package_info = packaging.read_package_info("aaa")
    assert package_info["version"] == "1.0"
    assert package_info["files"]["checks"] == ["aaa"]
    assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()