Bug 30128 - Inconsistent API for UCR modules
Inconsistent API for UCR modules
Status: RESOLVED WONTFIX
Product: UCS extended documentation
Classification: Unclassified
Component: Developer documentation
unspecified
Other Linux
: P5 normal (vote)
: ---
Assigned To: Docu maintainers
:
Depends on: 30127
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-23 14:11 CET by Sönke Schwardt-Krummrich
Modified: 2024-04-17 13:16 CEST (History)
0 users

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2013-01-23 14:11:53 CET
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.
Comment 1 Nico Gulden univentionstaff 2024-04-17 13:16:23 CEST
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.