#!/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_aruba_wlc_aps(info):
    map_ap_products = {
        "1": "a50",
        "2": "a52",
        "3": "a60",
        "4": "a61",
        "5": "a70",
        "6": "walljackAp61",
        "7": "a2E",
        "8": "ap1200",
        "9": "ap80s",
        "10": "ap80m",
        "11": "wg102",
        "12": "ap40",
        "13": "ap41",
        "14": "ap65",
        "15": "NesotMW1700",
        "16": "ortronics Wi Jack Duo",
        "17": "ortronics Duo",
        "18": "ap80MB",
        "19": "ap80SB",
        "20": "ap85",
        "21": "ap124",
        "22": "ap125",
        "23": "ap120",
        "24": "ap121",
        "25": "ap1250",
        "26": "ap120abg",
        "27": "ap121abg",
        "28": "ap124abg",
        "29": "ap125abg",
        "30": "rap5wn",
        "31": "rap5",
        "32": "rap2wg",
        "33": "reserved-4",
        "34": "ap105",
        "35": "ap65wb",
        "36": "ap651",
        "37": "reserved-6",
        "38": "ap60p",
        "39": "reserved-7",
        "40": "ap92",
        "41": "ap93",
        "42": "ap68",
        "43": "ap68p",
        "44": "ap175p",
        "45": "ap175ac",
        "46": "ap175dc",
        "47": "ap134",
        "48": "ap135",
        "49": "reserved-8",
        "50": "ap93h",
        "51": "rap3wn",
        "52": "rap3wnp",
        "53": "ap104",
        "54": "rap155",
        "55": "rap155p",
        "56": "rap108",
        "57": "rap109",
        "58": "ap224",
        "59": "ap225",
        "60": "ap114",
        "61": "ap115",
        "62": "rap109L",
        "63": "ap274",
        "64": "ap275",
        "65": "ap214a",
        "66": "ap215a",
        "67": "ap204",
        "68": "ap205",
        "69": "ap103",
        "70": "ap103H",
        "72": "ap227",
        "73": "ap214",
        "74": "ap215",
        "75": "ap228",
        "76": "ap205H",
        "9999": "undefined"
    }
    node = inv_tree_list("networking.wlan.controller.accesspoints:")
    for ap_name, _ap_status, _ap_unprovisioned, ap_ip, ap_group, \
        ap_model, ap_serial, ap_sysloc in info:
        node.append({
            "ip_addr": ap_ip,
            "name": ap_name,
            "group": ap_group,
            "model": map_ap_products.get(ap_model.split(".")[-1], "unknown"),
            "serial": ap_serial,
            "sys_location": ap_sysloc,
        })
    return node


inv_info['aruba_wlc_aps'] = {
    'inv_function': inv_aruba_wlc_aps,
}
