@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
    @checks_instance_lock
    def _detach_volume(self, context, instance_id, volume_id, destroy_bdm):
        """Detach a volume from an instance."""
        context = context.elevated()
        instance_ref = self.db.instance_get(context, instance_id)
        volume_ref = self.db.volume_get(context, volume_id)
        mp = volume_ref['mountpoint']
        LOG.audit(_("Detach volume %(volume_id)s from mountpoint %(mp)s"
                " on instance %(instance_id)s") % locals(), context=context)
        if instance_ref['name'] not in self.driver.list_instances():
            LOG.warn(_("Detaching volume from unknown instance %s"),
                     instance_id, context=context)
        else:
            self.driver.detach_volume(instance_ref['name'],
                                      volume_ref['mountpoint'])
        self.volume_manager.remove_compute_volume(context, volume_id)
        self.db.volume_detached(context, volume_id)
        if destroy_bdm:
            self.db.block_device_mapping_destroy_by_instance_and_volume(
                context, instance_id, volume_id)
        return True
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/compute/manager.py/ComputeManager._detach_volume/original