Univention Bugzilla – Bug 30128
Inconsistent API for UCR modules
Last modified: 2024-04-17 13:16:23 CEST
The current behaviour should be documented. The "ucr register" part is currently not documented in the public wiki. +++ This bug was initially created as a clone of Bug #30127 +++ If one or more UCR variables get changed, the handler() function of UCR modules will be called. This function gets two arguments: - a ConfigRegistry() object - a dictionary containing the changes → each key of that represents a UCR variable name → for each key a tuple consisting of old and new UCR value is stored handler(ucr, changes) → ucr: { 'cron/autostart': 'yes', 'update/secure_apt': 'yes', … } → changes: { 'changedUCRVariable1': ( 'oldValue', 'newValue' ), 'changedUCRVariable2': ( 'oldValue', 'newValue' ), 'newVariable': ( None, 'newValue' ), 'removedVariable': ( 'oldValue', '' ), 'VariableToEmptyString': ( 'oldValue', '' ), } During UCR module registration ("ucr register packagename") the second positional argument ("changes") contains no tuple but a simple string or None. Each variable that is specified in the .info-File ("Variables: ldap/hostdn") will be looked up for its current value that is stored in the dictionary. If regular expressions are used or the variable is unset, the value None is stored instead of a string. ---[foo.info]--- Type: module Module: foo.py Variables: foo/.* Variables: unknown/variable Variables: ldap/hostdn Variables: hostname --- Values passed as "changes" to handler() during "ucr register": {'hostname': 'master', 'unknown/variable': None, 'foo/.*': None, 'ldap/hostdn': 'cn=master,cn=dc,cn=computers,dc=nstx,dc=ucsschool' } There are some inconsistencies that should be fixed in future: - during registration: - all variables matching a given regexp should be expanded - a tuple of two values should be passed for each variable to the freshly registered module to be consistend with later API: { 'hostname': (None, 'master'), 'unknown/variable': (None, None), 'foo/bar': (None, 'test'), 'foo/baz': (None, 'test2'), 'ldap/hostdn': (None, 'cn=master,cn=dc,cn=computers,dc=example,dc=com') } - after registration when variables change: - when variables get removed, the old value and None should be stored in the "changes" dictionary, to be able to distinct variables that have been removed and variables that have been set to empty string.
This bug hasn't seen any update for several years. I close it. If you still see a need for it, you can reopen the bug. Please add an argumentation about why it's important to take care of it.