'Delete volume backup from configured backup service.'

def delete_backup(self, context, backup):

    LOG.info('Delete    backup    started,    backup:    %s.', backup.id)
    self._notify_about_backup_usage(context, backup, 'delete.start')
    backup.host = self.host
    backup.save()
    expected_status = fields.BackupStatus.DELETING
    actual_status = backup.status
    if (actual_status != expected_status):
        err = (_('Delete_backup    aborted,    expected    backup    status    %(expected_status)s    but    got    %(actual_status)s.') % {'expected_status': expected_status, 'actual_status': actual_status})
        self._update_backup_error(backup, err)
        raise exception.InvalidBackup(reason=err)
    if (not self.is_working()):
        err = _('Delete    backup    is    aborted    due    to    backup    service    is    down')
        status = fields.BackupStatus.ERROR_DELETING
        self._update_backup_error(backup, err, status)
        raise exception.InvalidBackup(reason=err)
    backup_service = self._map_service_to_driver(backup['service'])
    if (backup_service is not None):
        configured_service = self.driver_name
        if (backup_service != configured_service):
            err = (_('Delete    backup    aborted,    the    backup    service    currently    configured    [%(configured_service)s]    is    not    the    backup    service    that    was    used    to    create    this    backup    [%(backup_service)s].') % {'configured_service': configured_service, 'backup_service': backup_service})
            self._update_backup_error(backup, err)
            raise exception.InvalidBackup(reason=err)
        try:
            backup_service = self.service.get_backup_driver(context)
            backup_service.delete_backup(backup)
        except Exception as err:
            with excutils.save_and_reraise_exception():
                self._update_backup_error(backup, six.text_type(err))
    try:
        reserve_opts = {'backups': (-1), 'backup_gigabytes': (- backup.size)}
        reservations = QUOTAS.reserve(context, project_id=backup.project_id, **reserve_opts)
    except Exception:
        reservations = None
        LOG.exception('Failed    to    update    usages    deleting    backup')
    backup.destroy()
    if backup.parent_id:
        parent_backup = objects.Backup.get_by_id(context, backup.parent_id)
        if parent_backup.has_dependent_backups:
            parent_backup.num_dependent_backups -= 1
            parent_backup.save()
    if reservations:
        QUOTAS.commit(context, reservations, project_id=backup.project_id)
    LOG.info('Delete    backup    finished,    backup    %s    deleted.', backup.id)
    self._notify_about_backup_usage(context, backup, 'delete.end')
