Univention Bugzilla – Bug 49919
UDM API: dhcp/pool has 2 possible superordinates
Last modified: 2019-07-25 10:35:11 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 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')
use univention.admin.modules.superordinate_names() instead of accessing the "superordinate" attribute of a module directly.