Bug 50167 - "policies" different in UDM REST API and simple Python UDM API
"policies" different in UDM REST API and simple Python UDM API
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 5.0-2-errata
Assigned To: Florian Best
Iván.Delgado
https://git.knut.univention.de/univen...
:
Depends on: 50178 27816
Blocks: 56146
  Show dependency treegraph
 
Reported: 2019-09-10 12:12 CEST by Daniel Tröder
Modified: 2023-06-13 18:08 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
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): API change
Max CVSS v3 score:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2019-09-10 12:12:39 CEST
The UDM REST API (Bug #27816) now exposes the policies of a UDM object as a mapping:
    module_name -> List[DN, DN, ..]

For example:
-------------------------------------------------
{
        "policies/pwhistory": [], 
        "policies/nfsmounts": [], 
        "policies/memberpackages": [], 
        "policies/desktop": [], 
        "policies/ldapserver": [], 
        "policies/slavepackages": [], 
        "policies/registry": [
            "cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr"
        ], 
        "policies/admin_container": [], 
        "policies/umc": [], 
        "policies/dhcp_statements": [], 
        "policies/dhcp_routing": [], 
        "policies/dhcp_leasetime": [], 
        "policies/printserver": [], 
        "policies/dhcp_boot": [], 
        "policies/share_userquota": [], 
        "policies/repositoryserver": [], 
        "policies/masterpackages": [], 
        "policies/release": [], 
        "policies/dhcp_netbios": [], 
        "policies/repositorysync": [], 
        "policies/autostart": [], 
        "policies/dhcp_dns": [
            "cn=dhcp-dns-clear,cn=policies,ou=DEMOSCHOOL,dc=uni,dc=dtr"
        ], 
        "policies/maintenance": [], 
        "policies/dhcp_dnsupdate": [], 
        "policies/dhcp_scope": [], 
        "policies/print_quota": []
    }
-------------------------------------------------

This is a convenient encoding, but differs to the one in the Python UDM API.

Create a new version of the Python UDM API, that uses the same encoding.
(Or revert the UDM REST API to the previous one.)
Comment 1 Florian Best univentionstaff 2019-09-10 12:56:33 CEST
Can you show an example of the simple UDM API?
Comment 2 Daniel Tröder univentionstaff 2019-09-11 07:49:48 CEST
from univention.udm import UDM
mod = UDM.admin().version(1).get('container/ou')
for obj in mod.search():
     print(obj, obj.policies)

(GenericObject('container/ou', 'ou=DEMOSCHOOL,dc=uni,dc=dtr'), ['cn=dhcp-dns-clear,cn=policies,ou=DEMOSCHOOL,dc=uni,dc=dtr', 'cn=ou-default-ucr-policy,cn=policies,ou=demoschool,dc=uni,dc=dtr'])
(GenericObject('container/ou', 'ou=SchuleZwei,dc=uni,dc=dtr'), ['cn=dhcp-dns-clear,cn=policies,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=ou-default-ucr-policy,cn=policies,ou=schulezwei,dc=uni,dc=dtr'])
Comment 3 Florian Best univentionstaff 2022-02-21 18:36:26 CET
Merge Request changing policies = [policy_dns, ...] into {policy_type: [policy_dns, ...], ...} available in:

https://git.knut.univention.de/univention/ucs/-/merge_requests/283

>>> import univention.udm                                                                                                                                                                                                                     
>>> u = univention.udm.UDM.admin().version(3)                                                                                                                                                                                                 
>>> m = u.get('users/user')                                                                                                                                                                                                                   
>>> a = m.get('uid=demo_staff,cn=mitarbeiter,cn=users,ou=DEMOSCHOOL,l=school,l=dev')                                                                                                                                                          
>>> a.policies
{'policies/umc': ['cn=schoolimport-all,cn=UMC,cn=policies,l=school,l=dev'], 'policies/pwhistory': [], 'policies/desktop': []}
Comment 4 Florian Best univentionstaff 2022-11-15 09:38:19 CET
Policies can now be exposed as Dict[str, List[DN]] when using Version 3:

univention-directory-manager-modules.yaml
764c2983b4ee | feat(udm-simple): change list of policy DNs to mapping of policy type to list of policy DNs

univention-directory-manager-modules (15.0.13-24)
37d5aa1cba4d | chore(udm-simple): increase API version to 3
764c2983b4ee | feat(udm-simple): change list of policy DNs to mapping of policy type to list of policy DNs
Comment 5 Iván.Delgado univentionstaff 2022-11-15 11:29:43 CET
Verified:
 * Comment 3
 * ucs-test-udm
 * Advisory