def _detach_volume(self, ctxt, attach_info, volume, properties, force=False, remote=False):
    connector = attach_info['connector']
    connector.disconnect_volume(attach_info['conn']['data'], attach_info['device'])
    if remote:
        rpcapi = volume_rpcapi.VolumeAPI()
        rpcapi.terminate_connection(ctxt, volume, properties, force=force)
        rpcapi.remove_export(ctxt, volume)
    else:
        try:
            self.terminate_connection(ctxt, volume['id'], properties, force=force)
            self.remove_export(ctxt, volume['id'])
        except Exception as err:
            with excutils.save_and_reraise_exception():
                LOG.error((_LE('Unable to terminate volume connection: %(err)s.') % {'err': err}))
def _detach_volume(self, ctxt, attach_info, volume, properties, force=False, remote=False):
    connector = attach_info['connector']
    connector.disconnect_volume(attach_info['conn']['data'], attach_info['device'])
    if remote:
        rpcapi = volume_rpcapi.VolumeAPI()
        rpcapi.terminate_connection(ctxt, volume, properties, force=force)
        rpcapi.remove_export(ctxt, volume)
    else:
        try:
            self.terminate_connection(ctxt, volume['id'], properties, force=force)
            self.remove_export(ctxt, volume['id'])
        except Exception as err:
            with excutils.save_and_reraise_exception():
                LOG.error((_LE('Unable to terminate volume connection: %(err)s.') % {'err': err}))