#!/usr/bin/env python3

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

# edgeconfig.py
# Given a yaml config file (same as ansible inventory for a site), create a
# YAML file consumable by ansible as variables that configures the managmeent
# node for that site

from __future__ import absolute_import

import argparse
import nbhelper
import json
import os
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 = {
        "base_config": {
            "default": os.path.join(
                os.path.dirname(os.path.realpath(__file__)), "base_edgeconfig.yaml"
            ),
            "nargs": "?",
            "type": argparse.FileType("r"),
            "help": "Config (optional, default: base_edgeconfig.yaml)",
        },
    }

    args = nbhelper.initialize(extra_args)
    tenant = nbhelper.NBTenant()

    # use base_config for additional items
    yaml_out = yaml.safe_load(args.base_config.read())

    dhcpd_subnets = []
    dhcpd_interfaces = []

    # reverse zones aggregate across RFC1918 IP prefix
    dns_reverse_zones = nbhelper.NBDNSReverseZones()
    for prefix in tenant.get_prefixes().values():

        nbhelper.NBDNSForwardZone.get_fwd_zone(prefix)
        dns_reverse_zones.add_prefix(prefix)
        dhcpd_subnet = nbhelper.NBDHCPSubnet(prefix)
        dhcpd_if = dhcpd_subnet.dhcpd_interface

        if dhcpd_if and dhcpd_if not in dhcpd_interfaces:
            dhcpd_interfaces.append(dhcpd_if)

        dhcpd_subnets.append(dhcpd_subnet)

    # yaml_out["devices"] = nbhelper.NBDevice.all_devs()
    yaml_out["netprep_netplan"] = tenant.generate_netplan()
    yaml_out["dns_forward_zones"] = nbhelper.NBDNSForwardZone.all_fwd_zones()
    yaml_out["dns_reverse_zones"] = dns_reverse_zones
    yaml_out["dhcpd_subnets"] = dhcpd_subnets
    yaml_out["dhcpd_interfaces"] = dhcpd_interfaces

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