Univention Bugzilla – Bug 44838
(4.2) --dry-run increases username counter
Last modified: 2017-10-16 21:33:58 CEST
+++ This bug was initially created as a clone of Bug #42465 +++ I started an import with --dry-run which increased ucsschoolUsernameNextNumber: 7 to ucsschoolUsernameNextNumber: 9 Which should only happen in a real import situation. [..] Merge from 4.1 to 4.2 and QA in 4.2 too.
oops... all commits for 4.2 have been tagged for the 4.1r2 bug: r80497: UsernameHandler does not increase counter in LDAP with dry_run anymore r80499: advisories "dry_run" has to be set in __init__(), to prevent a dependency on the configuration singleton. Using the configuration object requires a lot of initialization that is not needed for this utility class. Overwriting UsernameHandler.get_storage_backend() allows to change the storage backend. Package: ucs-school-import Version: 15.0.0-5A~4.2.0.201706261618 Branch: ucs_4.2-0 Scope: ucs-school-4.2
REOPEN: * use ucr['ldap/base'] instead of lo.base * get_machine_connection() and get_admin_connection() is called at import time: + ldap_backend = LdapStorageBackend(get_machine_connection()) → calls get_machine_connection() +class LdapStorageBackend(UsernameCounterStorageBackend): + def __init__(self, lo=None, pos=None): + if lo and pos: + self.lo, _pos = lo, pos + else: + self.lo, _pos = get_admin_connection() → as pos is not given in the above call get_admin_connection() is called.
(In reply to Florian Best from comment #2) > REOPEN: > * use ucr['ldap/base'] instead of lo.base > * get_machine_connection() and get_admin_connection() is called at import > time: > + ldap_backend = LdapStorageBackend(get_machine_connection()) > → calls get_machine_connection() fixed > +class LdapStorageBackend(UsernameCounterStorageBackend): > + def __init__(self, lo=None, pos=None): > + if lo and pos: > + self.lo, _pos = lo, pos > + else: > + self.lo, _pos = get_admin_connection() > → as pos is not given in the above call get_admin_connection() is called. get_machine_connection() return a 2-tuple (lo, pos) r80505: don't create LDAP connection at import time r80506: advisories ucs-school-import (15.0.0-6A~4.2.0.201706271130)
REOPEN: (In reply to Daniel Tröder from comment #3) > > +class LdapStorageBackend(UsernameCounterStorageBackend): > > + def __init__(self, lo=None, pos=None): > > + if lo and pos: > > + self.lo, _pos = lo, pos > > + else: > > + self.lo, _pos = get_admin_connection() > > → as pos is not given in the above call get_admin_connection() is called. > get_machine_connection() return a 2-tuple (lo, pos) Yes, it returns a 2-tuple. And a 2-tuple is not two arguments. LdapStorageBackend(get_machine_connection()) → results in the call LdapStorageBackend((connection, position), None) where the parameter lo is (connection, position) and po is None. You can use LdapStorageBackend(*get_machine_connection())
oops... that's what was intended :) Fixed, commited (80535), yamled (80538).
OK: --dry-run causes the counter to not increased OK: for modifications the counter is not increased OK: YAML (adjusted in r80627)
r81125: adapt 215_import-users_illegal_chars_in_username_v2 to code changes
UCS@school 4.2 v4 has been released. http://docs.software-univention.de/changelog-ucsschool-4.2v4-de.html If this error occurs again, please clone this bug.