#!/usr/bin/python

DOCUMENTATION = '''
---
module: maas_zone
short_description: Manage MAAS Clusters Interfaces
options:
  maas:
    description:
      - URL of MAAS server
    default: http://localhost/MAAS/api/1.0/
  key:
    description:
      - MAAS API key
    required: yes
  name:
    description:
      - name of the zone
    required: yes
  description:
    description:
      - description text of zone
    required: no
  state:
    description:
      - possible states for this zone
    choices: ['present', 'absent', 'query']
    default: present

requirements: [ipaddress, requests_oauthlib, maasclient]
author: David Bainbridge
'''

EXAMPLES = '''
examples:
  maas_zone:
    maas: http://my.maas.server.com/MAAS/api/1.0/
    key: 'xBvr9dx5k7S52myufC:fqBXV7hJgXegNZDw9c:K8hsmL47XjAppfQy2pDVW7G49p6PELgp'
    name: MyZone
    description: This is my zone
    state: present

  maas_zone:
    maas: http://my.maas.server.com/MAAS/api/1.0/
    key: 'xBvr9dx5k7S52myufC:fqBXV7hJgXegNZDw9c:K8hsmL47XjAppfQy2pDVW7G49p6PELgp'
    name: MyDeadZone
    description: This was my zone
    state: absent
'''

import sys
import json
import ipaddress
import requests
from maasclient.auth import MaasAuth
from maasclient import MaasClient

# For some reason the maasclient doesn't provide a put method. So
# we will add it here
def put(client, url, params=None):
    return requests.put(url=client.auth.api_url + url,
                        auth=client._oauth(), data=params)

# Attempt to interpret the given value as a JSON object, if that fails
# just return it as a string
def string_or_object(val):
    try:
        return json.loads(val)
    except:
        return val

# Return a copy of the given dictionary with any `null` valued entries
# removed
def remove_null(d_in):
    d = d_in.copy()
    to_remove = []
    for k in d.keys():
        if d[k] == None:
            to_remove.append(k)
    for k in to_remove:
        del d[k]
    return d

# Deterine if two dictionaries are different
def different(have, want):
    have_keys = have.keys()
    for key in want.keys():
        if (key in have_keys and want[key] != have[key]) or key not in have_keys:
            return True
    return False

# Get an zone from MAAS using its name, if not found return None
def get_zone(maas, name):
    res = maas.get('/zones/%s/' % name)
    if res.ok:
        return json.loads(res.text)
    return None

# Create an zone based on the value given
def create_zone(maas, zone):
    merged = zone.copy()
    # merged['op'] = 'new'
    res = maas.post('/zones/', merged)
    if res.ok:
        return { 'error': False, 'status': get_zone(maas, merged['name']) }
    return { 'error': True, 'status': string_or_object(res.text) }

# Delete an zone based on the name
def delete_zone(maas, name):
    res = maas.delete('/zones/%s/' % name)
    if res.ok:
        return { 'error': False }
    return { 'error': True, 'status': string_or_object(res.text) }

def update_zone(maas, have, want):
    merged = have.copy()
    merged.update(want)
    res = put(maas, '/zones/%s/' % merged['name'], merged)
    if res.ok:
        return { 'error': False, 'status': get_zone(maas, merged['name']) }
    return { 'error': True, 'status': string_or_object(res.text) }

def main():
    module = AnsibleModule(
        argument_spec = dict(
            maas=dict(default='http://localhost/MAAS/api/1.0/'),
            key=dict(required=True),
            name=dict(required=True),
            description=dict(required=False),
            state=dict(default='present', choices=['present', 'absent', 'query'])
        ),
        supports_check_mode = False
    )

    maas = module.params['maas']
    key = module.params['key']
    state = module.params['state']

    # Construct a sparsely populate desired state
    desired = remove_null({
        'name': module.params['name'],
        'description': module.params['description'],
    })

    # Authenticate into MAAS
    auth = MaasAuth(maas, key)
    maas = MaasClient(auth)

    # Attempt to get the zone from MAAS
    zone = get_zone(maas, desired['name'])

    # Actions if the zone does not currently exist
    if not zone:
        if state == 'query':
            # If this is a query, returne it is not found
            module.exit_json(changed=False, found=False)
        elif state == 'present':
            # If this should be present, then attempt to create it
            res = create_zone(maas, desired)
            if res['error']:
                module.fail_json(msg=res['status'])
            else:
                module.exit_json(changed=True, zone=res['status'])
        else:
            # If this should be absent, then we are done and in the desired state
            module.exit_json(changed=False)

        # Done with zones does not exists actions
        return

    # Actions if the zone does exist
    if state == 'query':
        # If this is a query, return the zone
        module.exit_json(changed=False, found=True, zone=zone)
        return
    elif state == 'present':
        # If we want this to exists check to see if this is different and
        # needs updated
        if different(zone, desired):
            res = update_zone(maas, zone, desired)
            if res['error']:
                module.fail_json(msg=res['status'])
            else:
                module.exit_json(changed=True, zone=res['status'])
        else:
            # No differences, to nothing to change
            module.exit_json(changed=False, zone=zone)
    else:
        # If we don't want this zone, then delete it
        res = delete_zone(maas, zone['name'])
        if res['error']:
            module.fail_json(msg=res['status'])
        else:
            module.exit_json(changed=True, zone=zone)

# this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
if __name__ == '__main__':
    main()
