Exemplo n.º 1
0
def test_config_parts():
    assert packaging.get_config_parts() == [
        packaging.PackagePart(
            "ec_rule_packs", "Event Console rule packs",
            "%s/mkeventd.d/mkp/rule_packs" %
            cmk.utils.paths.default_config_dir)
    ]
Exemplo n.º 2
0
def package_pack(args: List[str]) -> None:
    if len(args) != 1:
        raise PackageException("Usage: check_mk -P pack NAME")

    # Make sure, user is not in data directories of Checkmk
    abs_curdir = os.path.abspath(os.curdir)
    for directory in [cmk.utils.paths.var_dir] + [
            p.path for p in get_package_parts() + get_config_parts()
    ]:
        if abs_curdir == directory or abs_curdir.startswith(directory + "/"):
            raise PackageException(
                "You are in %s!\n"
                "Please leave the directories of Check_MK before creating\n"
                "a packet file. Foreign files lying around here will mix up things."
                % abs_curdir)

    pacname = args[0]
    package = read_package_info(pacname)
    if not package:
        raise PackageException("Package %s not existing or corrupt." % pacname)
    tarfilename = packaging.format_file_name(name=pacname,
                                             version=package["version"])

    logger.log(VERBOSE, "Packing %s into %s...", pacname, tarfilename)
    with Path(tarfilename).open("wb") as f:
        packaging.write_file(package, cast(BinaryIO, f))
    logger.log(VERBOSE, "Successfully created %s", tarfilename)
Exemplo n.º 3
0
def package_find(_no_args: List[str]) -> None:
    first = True
    for part in get_package_parts() + get_config_parts():
        files = unpackaged_files_in_dir(part.ident, part.path)
        if len(files) > 0:
            if first:
                logger.log(VERBOSE, "Unpackaged files:")
                first = False

            logger.log(VERBOSE, "  %s%s%s:", tty.bold, part.title, tty.normal)
            for f in files:
                if logger.isEnabledFor(VERBOSE):
                    logger.log(VERBOSE, "    %s", f)
                else:
                    logger.info("%s/%s", part.path, f)

    if first:
        logger.log(VERBOSE, "No unpackaged files found.")
Exemplo n.º 4
0
def test_get_config_parts():
    assert [p.ident for p in packaging.get_config_parts()] == ["ec_rule_packs"]