Bug 41659 - unify computers/* code
unify computers/* code
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal with 1 vote (vote)
: UCS 4.4-0-errata
Assigned To: Florian Best
Philipp Hahn
:
: 27857 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-06-27 11:11 CEST by Florian Best
Modified: 2019-08-02 17:21 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Development Internal
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): Cleanup
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch (144.37 KB, patch)
2016-07-01 00:27 CEST, Florian Best
Details | Diff
patch (rebased to r80805) (141.85 KB, patch)
2017-07-03 19:31 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-06-27 11:11:45 CEST
There is a lot of redundant code in the computers/* UDM handlers.
Especially the open/_ldap_addlist/_ldap_modlist/_ldap_{pre,post}_{create,modify,delete} methods are nearly the same in every handler.

We should outsource that code into external classes/methods/functions.
Comment 1 Florian Best univentionstaff 2016-07-01 00:27:37 CEST
Created attachment 7781 [details]
patch

Attached a patch which behaves exactly the same as before except:
* when creating a domaincontroller_master / windows_domaincontroller the 'kerberos' option is removed if univention.admin.uldap.domain(self.lo, self.position).getKerberosRealm() returns None.
→ This is the behavior of DC {backup,slave,memberserver} and should be okay here, too.
* The 'computers/memberserver' lookup() functions finds memberserver only if they have univentionServerRole=='member' set. This is automatically set when creating a memberserver.
Comment 2 Florian Best univentionstaff 2016-10-10 16:14:28 CEST
*** Bug 27857 has been marked as a duplicate of this bug. ***
Comment 3 Florian Best univentionstaff 2017-07-03 19:31:27 CEST
Created attachment 8993 [details]
patch (rebased to r80805)
Comment 4 Stefan Gohmann univentionstaff 2019-01-03 07:22:30 CET
This issue has been filled against UCS 4.1. The maintenance with bug and security fixes for UCS 4.1 has ended on 5st of April 2018.

Customers still on UCS 4.1 are encouraged to update to UCS 4.3. Please contact
your partner or Univention for any questions.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or simply reopen the issue. In this case please provide detailed information on how this issue is affecting you.
Comment 5 Florian Best univentionstaff 2019-03-14 16:07:44 CET
I splitted the fix into 3 commits:
* The first commit is the patch I already had, slightly changed.

* The second commit makes sure that no behavior change exists:
(In reply to Florian Best from comment #1)
> Attached a patch which behaves exactly the same as before except:
> * when creating a domaincontroller_master / windows_domaincontroller the
> 'kerberos' option is removed if univention.admin.uldap.domain(self.lo,
> self.position).getKerberosRealm() returns None.
> → This is the behavior of DC {backup,slave,memberserver} and should be okay
> here, too.
> * The 'computers/memberserver' lookup() functions finds memberserver only if
> they have univentionServerRole=='member' set. This is automatically set when
> creating a memberserver.
Both points are reverted to the old behavior. Maybe this is unnecessary, but who knows?!

The third commits adds some extra things because UDM has evolved since 2016 and some features of that can be used.

univention-directory-manager-modules (14.0.12-4)
9ff4a2152768 | Bug #41659: Merge branch 'fbest/41659-unify-computers' into 4.4-0
1234da7da7e5 | Bug #41659: further adjustments to current UDM
f4d198f8c55d | Bug #41659: make behavior equal to prior
79b616a8f27e | Bug #41659: unify computer/* handlers to share a common python base

univention-directory-manager-modules (14.0.12-5)
52409a26e6a7 | Bug #41659: all computer/* handlers have been unified into one base class

univention-directory-manager-modules (14.0.12-6)
ccf036f7c9e8 | Bug #41659: use ln -snf (Feedback from QA)

univention-directory-manager-modules.yaml
7a707c26b06e | YAML Bug #41659
Comment 6 Philipp Hahn univentionstaff 2019-03-14 16:28:24 CET
OK: ccf036f7c9 Bug #41659: use ln -snf (Feedback from QA)
OK: 7a707c26b0 YAML Bug #41659
OK: 52409a26e6 Bug #41659: all computer/* handlers have been unified into one base class
OK: 9ff4a21527 Bug #41659: Merge branch 'fbest/41659-unify-computers' into 4.4-0
OK: 1234da7da7 Bug #41659: further adjustments to current UDM
OK: f4d198f8c5 Bug #41659: make behavior equal to prior
OK: 79b616a8f2 Bug #41659: unify computer/* handlers to share a common python base

OK: 66_udm-computers/22_all_roles_modification_append_and_remove_groups -vvvf
OK: 66_udm-computers/22_all_roles_modification_append_and_remove_groups -vvvf
Comment 7 Florian Best univentionstaff 2019-03-15 09:18:35 CET
Typo, breaks jenkins:
-»   »   »   »   »   if not (ip in removedIPs or mac in removedMACs)
+»   »   »   »   »   if not (ip in removedIPs or _mac in removedMACs)
Comment 8 Philipp Hahn univentionstaff 2019-03-15 10:56:26 CET
(In reply to Florian Best from comment #7)
> Typo, breaks jenkins:
> -»   »   »   »   »   if not (ip in removedIPs or mac in removedMACs)
> +»   »   »   »   »   if not (ip in removedIPs or _mac in removedMACs)

Please revert the change in handers/__init__.py from commit 1234da7da7e52a41d9321be6c85c8da207ca1a3a
Comment 9 Felix Botner univentionstaff 2019-03-15 11:29:16 CET
60_umc.03_acls.test fails because of this, as far i as understood, the problem for the umc server is

/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py
  @classmethod
        def rewrite_filter(cls, filter, mapping):
                key = filter.variable
                mod = univention.admin.modules.get(cls.module)
                try:
                    property_ = mod.property_descriptions.get(key)
                except Exception as exc:

mod is None because modules.update() is missing
Comment 10 Florian Best univentionstaff 2019-03-15 12:00:06 CET
Both points fixed. Package has already been built.
Comment 11 Philipp Hahn univentionstaff 2019-03-20 07:51:33 CET
OK: 8cce7e143605705db725d0b11881fc601e32f409
OK: 4da065177b5bd023cf3a15706a224d9af280d7d0
OK: bb03a8758bf0b909a2c78fed0e2ba7f54322425e
OK: vimdiff handlers/computers/*.py
OK: Jenkins
Comment 12 Dirk Wiesenthal univentionstaff 2019-03-26 20:51:25 CET
See https://forge.univention.org/bugzilla/show_bug.cgi?id=48895#c6. Looks like the new python file is not linked yet during the update process. Can you please check this?
Comment 13 Florian Best univentionstaff 2019-03-27 07:54:31 CET
(In reply to Dirk Wiesenthal from comment #12)
> See https://forge.univention.org/bugzilla/show_bug.cgi?id=48895#c6. Looks
> like the new python file is not linked yet during the update process. Can
> you please check this?

It is linked in preinst:
python-univention-directory-manager.preinst:»   ln -snf /usr/share/pyshared/univention/admin/handlers/computers/base.py /usr/lib/pymodules/python2.7/univention/admin/handlers/computers/base.py
Comment 14 Florian Best univentionstaff 2019-03-27 09:15:46 CET
univention-directory-manager-modules (14.0.12-17)
e376c48f303b | Bug #41659: call update-python-modules explicit
Comment 15 Philipp Hahn univentionstaff 2019-03-27 12:23:03 CET
OK: 3dbb99c814a11d2ab92fc3b16b36e8cc37cc009a
OK: e376c48f303b41918bcf0b4733e1e0fe522f5584

OK: f458d7180dce6d8f8355bb4bee99654fe8861c72
OK: 76947b61f3c8fca3bdd3fcedb357f876afe3decd

OK: grep ERROR /var/log/univention/listener.log
OK: ucs-test -E dangerous -c -s udm-computers
OK: http://jenkins.knut.univention.de:8080/job/UCS-4.4/job/UCS-4.4-0/view/Branch%20Tests/job/branch%20test%20base%20singlemaster/
Comment 16 Arvid Requate univentionstaff 2019-03-27 13:29:17 CET
<http://errata.software-univention.de/ucs/4.4/19.html>