Frees a reserved address range from a virtual network.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to free an address range.
        Can be used instead of ``vn_name``.

    vn_name
        The name of the virtual network from which to free an address range.
        Can be used instead of ``vn_id``.

    ar_id
        The ID of the address range to free.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_free_ar opennebula vn_id=3 ar_id=1
        salt-cloud -f vn_free_ar opennebula vn_name=my-vn ar_id=1

def vn_free_ar(call=None, kwargs=None):
    '''
    Frees a reserved address range from a virtual network.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to free an address range.
        Can be used instead of ``vn_name``.

    vn_name
        The name of the virtual network from which to free an address range.
        Can be used instead of ``vn_id``.

    ar_id
        The ID of the address range to free.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_free_ar opennebula vn_id=3 ar_id=1
        salt-cloud -f vn_free_ar opennebula vn_name=my-vn ar_id=1
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The vn_free_ar function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    vn_id = kwargs.get('vn_id', None)
    vn_name = kwargs.get('vn_name', None)
    ar_id = kwargs.get('ar_id', None)

    if ar_id is None:
        raise SaltCloudSystemExit(
            'The vn_free_ar function requires an \'rn_id\' to be provided.'
        )

    if vn_id:
        if vn_name:
            log.warning(
                'Both the \'vn_id\' and \'vn_name\' arguments were provided. '
                '\'vn_id\' will take precedence.'
            )
    elif vn_name:
        vn_id = get_vn_id(kwargs={'name': vn_name})
    else:
        raise SaltCloudSystemExit(
            'The vn_free_ar function requires a \'vn_id\' or a \'vn_name\' to '
            'be provided.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    response = server.one.vn.free_ar(auth, int(vn_id), int(ar_id))

    data = {
        'action': 'vn.free_ar',
        'ar_freed': response[0],
        'resource_id': response[1],
        'error_code': response[2],
    }

    return data