'Deletes and unexports snapshot.'

@coordination.synchronized('{snapshot.id}-{f_name}')
def delete_snapshot(self, context, snapshot, unmanage_only=False, handle_quota=True):

    context = context.elevated()
    snapshot._context = context
    project_id = snapshot.project_id
    self._notify_about_snapshot_usage(context, snapshot, 'delete.start')
    try:
        utils.require_driver_initialized(self.driver)
        snapshot.context = context
        snapshot.save()
        if unmanage_only:
            self.driver.unmanage_snapshot(snapshot)
        else:
            self.driver.delete_snapshot(snapshot)
    except exception.SnapshotIsBusy:
        LOG.error('Delete    snapshot    failed,    due    to    snapshot    busy.', resource=snapshot)
        snapshot.status = fields.SnapshotStatus.AVAILABLE
        snapshot.save()
        return
    except Exception:
        with excutils.save_and_reraise_exception():
            snapshot.status = fields.SnapshotStatus.ERROR_DELETING
            snapshot.save()
    reservations = None
    try:
        if handle_quota:
            if CONF.no_snapshot_gb_quota:
                reserve_opts = {'snapshots': (-1)}
            else:
                reserve_opts = {'snapshots': (-1), 'gigabytes': (- snapshot.volume_size)}
            volume_ref = self.db.volume_get(context, snapshot.volume_id)
            QUOTAS.add_volume_type_opts(context, reserve_opts, volume_ref.get('volume_type_id'))
            reservations = QUOTAS.reserve(context, project_id=project_id, **reserve_opts)
    except Exception:
        reservations = None
        LOG.exception('Update    snapshot    usages    failed.', resource=snapshot)
    self.db.volume_glance_metadata_delete_by_snapshot(context, snapshot.id)
    snapshot.destroy()
    self._notify_about_snapshot_usage(context, snapshot, 'delete.end')
    if reservations:
        QUOTAS.commit(context, reservations, project_id=project_id)
    msg = 'Delete    snapshot    completed    successfully.'
    if unmanage_only:
        msg = 'Unmanage    snapshot    completed    successfully.'
    LOG.info(msg, resource=snapshot)
