Bug 49919 - UDM API: dhcp/pool has 2 possible superordinates
UDM API: dhcp/pool has 2 possible superordinates
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on:
Blocks: 49913
  Show dependency treegraph
 
Reported: 2019-07-25 09:13 CEST by Philipp Hahn
Modified: 2019-07-25 10:35 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.046
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
Convert legacy dhcp ranges to pools (534 bytes, text/plain)
2019-07-25 09:13 CEST, Philipp Hahn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2019-07-25 09:13:30 CEST
Created attachment 10133 [details]
Convert legacy dhcp ranges to pools

While working on Bug #49913 I noticed that the UDM API does not handle "dhcp/pool" correctly: that type has two possible superordinates:
- dhcp/subnet
- dhcp/sharedsubnet

When the object is created by calling "pool.save()" an exception is thrown:

>>> pool.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/univention/udm/modules/generic.py", line 166, in save
    self._copy_to_udm_obj()
  File "/usr/lib/pymodules/python2.7/univention/udm/modules/generic.py", line 346, in _copy_to_udm_obj
    self._udm_module.meta.used_api_version
  File "/usr/lib/pymodules/python2.7/univention/udm/modules/generic.py", line 508, in __init__
    self._orig_udm_module = self._get_orig_udm_module()
  File "/usr/lib/pymodules/python2.7/univention/udm/modules/generic.py", line 619, in _get_orig_udm_module
    if key not in self._udm_module_cache:
TypeError: unhashable type: 'list'


(Pdb) print self._udm_module._orig_udm_module.superordinate
['dhcp/subnet', 'dhcp/sharedsubnet']


"dhcp/pool" is the only module having multiple superordinates:
  git grep ^superordinate -- management/univention-directory-manager-modules/modules/univention/admin/handlers
...
.../dhcp/host.py:superordinate = 'dhcp/service'
.../dhcp/pool.py:superordinate = ['dhcp/subnet', 'dhcp/sharedsubnet']
...
Comment 1 Philipp Hahn univentionstaff 2019-07-25 09:26:35 CEST
Comment on attachment 10133 [details]
Convert legacy dhcp ranges to pools

Workaound:
  pool.superordinate = obj
before pool.save()

>>> pool = m_pool.new(superordinate=obj)
>>> pool.superordinate
'cn=192.0.2.0,cn=test,dc=phahn,dc=dev'
>>> obj
GenericObject('dhcp/subnet', 'cn=192.0.2.0,cn=test,dc=phahn,dc=dev')
Comment 2 Florian Best univentionstaff 2019-07-25 10:35:11 CEST
use univention.admin.modules.superordinate_names() instead of accessing the "superordinate" attribute of a module directly.