#!/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.

# NOTE: Careful when replacing the *-import below with a more specific import. This can cause
# problems because it might remove variables from the check-context which are necessary for
# resolving legacy discovery results such as [("SUMMARY", "diskstat_default_levels")]. Furthermore,
# it might also remove variables needed for accessing discovery rulesets.
from cmk.base.check_legacy_includes.ddn_s2a import *  # pylint: disable=wildcard-import,unused-wildcard-import


def parse_ddn_s2a_version(info):
    return {key: value[0] for key, value in parse_ddn_s2a_api_response(info).items()}


def inventory_ddn_s2a_version(parsed):
    return [(None, None)]


def check_ddn_s2a_version(_no_item, _no_params, parsed):
    yield 0, "Platform: %s" % parsed["platform"]
    yield 0, "Firmware Version: %s (%s)" % (parsed["fw_version"], parsed["fw_date"])
    yield 0, "Bootrom Version: %s" % parsed["bootrom_version"]


check_info["ddn_s2a_version"] = {
    "parse_function": parse_ddn_s2a_version,
    "inventory_function": inventory_ddn_s2a_version,
    "check_function": check_ddn_s2a_version,
    "service_description": "DDN S2A Version",
}
