Cerebrum changelog implementations

Overview of existing Cerebrum.ChangeLog functionality and implementations.

Existing functionality

Cerebrum.ChangeLog:ChangeLog

The core ChangeLog implements an abstract ChangeLog API

  • log_change queues a change event
  • write_log flushes the queue
  • clear_log clears the queue
  • publish_log finalizes/commits flushed changes
  • unpublish_log aborts/performs a rollback of flushed changes
Cerebrum.modules.ChangeLog (mod_changelog)

The core ChangeLog implementation in Cerebrum. Changes here are written to the change_log table in Cerebrum.

Implementation details:

  • write_log writes queued changes to the database
  • Depends on database commit for persistence
  • Provides additional methods for changelog lookup

write_log called inconsistently -- depends on CLDatabase.commit!

Cerebrum.modules.CLHandler (mod_changelog)

Maps changelog data from the change_log table to keys in a change_handler_data table. The mapping table tags ranges of change_log rows, and is used to mark certain change_log entries as processed by some script.

This is the basis for «quicksync» scripts.

Used by:

  • Cerebrum.modules.ad2.ADSync (quicksync)
  • Cerebrum.modules.no.uio.ADSync (quicksync)
  • contrib/dump_usernames_passwords.py (username and password export)
  • contrib/generate_event_list.py (generate a JSON export over changes)
  • contrib/no/Indigo/create_users.py (create users for all events of type auto_create
  • contrib/no/uio/sync_ephorte_persons.py (ephorte quicksync)
  • contrib/no/uio/process_changes.py (build user disks, prepare student accounts)
  • contrib/no/uio/generate_quarantine_email_notifications.py (monitor and send email summary on quarantines)
  • contrib/update-ou-group-changes.py (monitor for ou changes and generate changelog for virtualgroups)
Cerebrum.modules.CLConstants
Changelog constants - identifies possible changes in the changelog database tables. Moved to Cerebrum.Constants as they were used by implementations outside of Cerebrum.modules. Changetypes and changes spread across Cerebrum submodules. Originally available in cerebrum.CLASS_CLCONSTANTS, also now avaialble in cereconf.CLASS_CONSTANTS as some constants were not available in CLASS_CLCONSTANTS.
Cerebrum.CLDatabase

Integrates an abstract database object with a changelog implementation.

Implementation details:

  • commit will cause a write_log followed by a publish_log (or unpublish_log in case of errors)
  • rollback will cause a clear_log
Cerebrum.modules.EventLog (mod_eventlog)

Implements basic event brokering (topic fanout) of events. Each logged change may be written to the database with a accopanying topic tags.

The event log contains additional fields to tag events with processing results (consumed, locked, failed, etc...). The Exchange integration implements database listeners/consumers that process these events as soon as they have been commited to the database.

Cerebrum.modules.event_publisher.eventlog (mod_events)
Implements a basic event queue, without brokering or error handling. The Cerebrum.modules.event_publisher contains additional functionality for consuming the queue sending events as messages to a message broker.
Cerebrum.modules.CLProcessors
Contains some basic support for grouping and printing some changelog events. Only used by contrib/statistics/generate_changelog_statistics.py to dump partial changelog statistics - and the module otherwise serves little to no purpose.
Cerebrum.modules.virthome.ChangeLogVH (mod_virthome)
Extends Cerebrum.modules.ChangeLog with an option of generating a one-time key for changes. The keys are used as credentials for password resets and other user prompts.
bofhd
user_history:
Lists changes done to an account object.
entity_history
Lists changes done to any Cerebrum object.

Cerebrum.modules.ChangeLog

Model

Table: mod_changelog

tstamp
When a change was logged.
change_id
Numerical ID of the change
subject_entity
Which entity was changed. May cause record to be deleted.
dest_entity
What other object does the change refer to (group memberships, traits). May cause record to be deleted.
change_type_id
Numerical ID of the change type
change_by
Which entity caused the change (typically an account entity). May cause record to be deleted.
change_program
What process caused the change (typically a batch job)
change_params
Additional information about the change, used very vaiable.
Av fhl
Publisert 9. feb. 2024 11:38