Detaches a disk from a virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM from which to detach the disk.

    disk_id
        The ID of the disk to detach.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_detach my-vm disk_id=1

def vm_detach(name, kwargs=None, call=None):
    '''
    Detaches a disk from a virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM from which to detach the disk.

    disk_id
        The ID of the disk to detach.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_detach my-vm disk_id=1
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The vm_detach action must be called with -a or --action.'
        )

    if kwargs is None:
        kwargs = {}

    disk_id = kwargs.get('disk_id', None)
    if disk_id is None:
        raise SaltCloudSystemExit(
            'The vm_detach function requires a \'disk_id\' to be provided.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    vm_id = int(get_vm_id(kwargs={'name': name}))
    response = server.one.vm.detach(auth, vm_id, int(disk_id))

    data = {
        'action': 'vm.detach',
        'detached': response[0],
        'vm_id': response[1],
        'error_code': response[2],
    }

    return data