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

from itertools import chain


def agent_ipmi_sensors_arguments(params, hostname, ipaddress):
    ipmi_command, options = params
    return [
        ipaddress,
        options["username"],
        options["password"],
        ipmi_command,
        options["privilege_lvl"],
        *chain.from_iterable((
            opt,
            value,
        ) for opt, parameter in [
            ("--driver", "ipmi_driver"),
            ("--driver_type", "driver_type"),
            ("--key", "BMC_key"),
            ("--intf", "intf"),
        ] if (value := options.get(parameter))),
        *(flag for flag, checkbox in [
            ("--quiet_cache", "quiet_cache"),
            ("--sdr_cache_recreate", "sdr_cache_recreate"),
            ("--interpret_oem_data", "interpret_oem_data"),
            ("--output_sensor_state", "output_sensor_state"),
            ("--ignore_not_available_sensors", "ignore_not_available_sensors"),
            ("--output_sensor_thresholds", "output_sensor_thresholds"),
        ] if options.get(checkbox)),
    ]


special_agent_info['ipmi_sensors'] = agent_ipmi_sensors_arguments
