'Disconnect the volume from the host.
With the force parameter we can indicate if we give more importance to
cleaning up as much as possible or if data integrity has higher
priority.  This requires the latests OS-Brick code that adds this
feature.
We can also force errors to be ignored using ignore_errors.'

def _detach_volume(self, context, attach_info, volume, properties, force=False, remote=False, ignore_errors=False):

    exc = brick_exception.ExceptionChainer()
    if attach_info:
        connector = attach_info['connector']
        with exc.context(force, 'Disconnect    failed'):
            connector.disconnect_volume(attach_info['conn']['data'], attach_info['device'], force=force, ignore_errors=ignore_errors)
    if remote:
        rpcapi = volume_rpcapi.VolumeAPI()
        with exc.context(force, 'Remote    terminate    connection    failed'):
            rpcapi.terminate_connection(context, volume, properties, force=force)
    else:
        with exc.context(force, _('Unable    to    terminate    volume    connection')):
            try:
                self.terminate_connection(volume, properties, force=force)
            except Exception as err:
                err_msg = (_('Unable    to    terminate    volume    connection:    %(err)s') % {'err': err})
                LOG.error(err_msg)
                raise exception.VolumeBackendAPIException(data=err_msg)
        with exc.context(force, _('Unable    to    remove    export')):
            try:
                LOG.debug('volume    %s:    removing    export', volume['id'])
                self.remove_export(context, volume)
            except Exception as ex:
                LOG.exception('Error    detaching    volume    %(volume)s,    due    to    remove    export    failure.', {'volume': volume['id']})
                raise exception.RemoveExportException(volume=volume['id'], reason=ex)
    if (exc and (not ignore_errors)):
        raise exc
