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


def inv_ibm_mq_managers(parsed, inventory_tree, status_data_tree):
    path = "software.applications.ibm_mq.managers:"
    inv_node = inventory_tree.get_list(path)
    status_node = status_data_tree.get_list(path)
    for qmname in sorted(parsed):
        attrs = parsed[qmname]
        key = {"name": qmname}

        data = dict(key)
        data["instver"] = attrs["INSTVER"]
        data["instname"] = attrs["INSTNAME"]
        data["ha"] = attrs.get("HA", "n/a")
        inv_node.append(data)

        data = dict(key)
        data["standby"] = attrs["STANDBY"]
        data["status"] = attrs["STATUS"]
        status_node.append(data)


inv_info['ibm_mq_managers'] = {
    'inv_function': inv_ibm_mq_managers,
    'has_status_data': True,
}
