#!/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_aix_service_packs(info):
    latest_service_pack = None
    service_packs = []
    for line in info:
        if line[0].startswith("----") or line[0].startswith("Known"):
            continue
        if latest_service_pack is None:
            latest_service_pack = line[0]
        else:
            service_packs.append(line[0])

    node = inv_tree("software.os.")
    node["service_pack"] = latest_service_pack

    node = inv_tree_list("software.os.service_packs:")
    for service_pack in service_packs:
        node.append({"name": service_pack})


inv_info['aix_service_packs'] = {
    "inv_function": inv_aix_service_packs,
}
