'Detaches a volume from a node.
@inherits :class:`NodeDriver.detach_volume`
:keyword ex_instance_id: the id of the instance from which the volume
is detached.
:type ex_instance_id: ``str``'

def detach_volume(self, volume, ex_instance_id=None):

    params = {'Action': 'DetachDisk', 'DiskId': volume.id}
    if ex_instance_id:
        params['InstanceId'] = ex_instance_id
    else:
        volumes = self.list_volumes(ex_volume_ids=[volume.id])
        if (len(volumes) != 1):
            raise AttributeError(('could    not    find    the    instance    id    the    volume    %s    attached    to,    ex_instance_id    is    required.' % volume.id))
        params['InstanceId'] = volumes[0].extra['instance_id']
    resp = self.connection.request(self.path, params)
    return resp.success()
