#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

#   .--only_from-----------------------------------------------------------.
#   |                       _            __                                |
#   |            ___  _ __ | |_   _     / _|_ __ ___  _ __ ___             |
#   |           / _ \| '_ \| | | | |   | |_| '__/ _ \| '_ ` _ \            |
#   |          | (_) | | | | | |_| |   |  _| | | (_) | | | | | |           |
#   |           \___/|_| |_|_|\__, |___|_| |_|  \___/|_| |_| |_|           |
#   |                         |___/_____|                                  |
#   '----------------------------------------------------------------------'

# Target value for agent's IP access configuration. Only if this
# is not None, the inventory will create services
check_mk_only_from_default = None


def check_only_from(_no_item, _no_params, _no_info):
    return (
        3,
        """This has been included in the service "Check_MK" (see long output for details).
The functionality of this service has been incorporated in the "Check_MK" service.
 The corresponding global config option "check_mk_only_from_default"
 will no longer work; please remove it from your main.mk file if
 you have been using this service.
 From now on this feature can be configured via WATO using the
 ruleset "Allowed IP addresses for agent access" - the same rule that
 will be used for the agent bakery (if available).
 The check state will be displayed as part of the "Check_MK" sercice.
""",
    )


check_info["check_mk.only_from"] = {
    "check_function": check_only_from,
    "inventory_function": lambda info: [],
    "service_description": "Check_MK Agent Access",
}
