#!/usr/bin/env python2.7
from argparse import ArgumentParser
import json
import yaml
import logging

from maas_client import MAASClient, MAASDispatcher, MAASOAuth
from maasng import list_dnsresources

parser = ArgumentParser()
parser.add_argument('--address_pool', help='Path to address_pool \
                    yaml file', required=True)
parser.add_argument('--debug', action='store_true', default=False)

def maas_IPAM():
    args = parser.parse_args()

    handler = logging.StreamHandler()

    if args.debug:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO

    LOG = logging.getLogger()
    LOG.setLevel(log_level)
    LOG.addHandler(handler)

    with open(args.address_pool, 'r') as f:
        yaml_data = yaml.safe_load(f)

    # TODO: (dstremkouski)
    # schema validator for address pool
    address_pool = yaml_data["parameters"]["address_pool"]
    dnsresources = list_dnsresources()

    for dnsres in dnsresources:
        mapping_found = False
        for net in address_pool:
            if net == 'external':
                continue
            if mapping_found:
                continue
            for addr in address_pool[net]['pool']:
                if dnsres["hostname"] == addr:
                    address_pool[net]['pool'][addr] = dnsres["ip_addresses"][0]
                    mapping_found = True
                    break

    return('{"address_pool": ' + json.dumps(address_pool) + '}')

if __name__ == "__main__":
    print maas_IPAM()
