#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0

# pxeconfig.py
# Given a yaml config file (same as ansible inventory for a site), create a
# YAML file consumable by ansible that has input for the pxeboot role, for creating
# preseed files for servers

from __future__ import absolute_import

import nbhelper
import json
import pprint

from ruamel import yaml

# main function that calls other functions
if __name__ == "__main__":

    # this is passed to argparse, key is option name, rest is kwargs
    extra_args = {
        "domain_extension": {
            "default": "aetherproject.net",
            "nargs": "?",
            "type": ascii,
            "help": "Domain extension (optional, default: aetherproject.net)",
        },
    }

    args = nbhelper.parse_cli_args(extra_args)
    nbh = nbhelper.NBHelper(args)

    yaml_out = {}
    pxeboot_hosts = []

    prefixes = nbh.all_prefixes()
    devices = nbhelper.NBDevice.all_devs()

    for dev_id, device in devices.items():

        # only pxeboot for servers
        if device.data["device_role"]["slug"] == "server":

            pxe_dev = {}
            pxe_dev["serial"] = device.data["serial"]
            pxe_dev["hostname"] = device.data["name"]
            pxe_dev["domain"] = args.domain_extension
            pxe_dev["mac_address"] = device.primary_iface()["mac_address"].lower()

            pxeboot_hosts.append(pxe_dev)

    #    yaml_out["devices"] = devices
    yaml_out["pxeboot_hosts"] = pxeboot_hosts

    print(yaml.safe_dump(yaml_out, indent=2))
