KeyError: 'ucsschoolRole' in computerroom/room/aquire and schoolwizards/computers/query

With the UCS@school errata update from 2019-09-11, we published a fix for Bug #49311 that changed the internal behavior of the SchoolComputer.lookup() method.

This introduced a regression in the script /usr/share/ucs-school-import/scripts/migrate_ucsschool_roles which caused it to skip certain computer objects during migration. This can cause tracebacks in parts of UCS@school that rely on the ucsschoolRole attribute to be present in SchoolComputers:

Interner Server-Fehler in "computerroom/room/acquire".
Request: computerroom/room/acquire

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 358, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 261, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 145, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/computerroom/__init__.py", line 392, in room_acquire
    self._italc.room = roomDN
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/computerroom/italc2.py", line 647, in room
    self._set(value)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 145, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/computerroom/italc2.py", line 709, in _set
    computers = list(computerroom.get_computers(lo))
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/group.py", line 288, in get_computers
    yield SchoolComputer.from_dn(host, self.school, ldap_connection)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 935, in from_dn
    return cls.from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 323, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 869, in from_udm_obj
    return klass.from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 323, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 876, in from_udm_obj
    udm_value = udm_obj[attr.udm_name]
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 478, in __getitem__
    elif key not in self.__no_default and self.descriptions[key].editable:
KeyError: 'ucsschoolRole'
Interner Server-Fehler in "schoolrooms/computers".
Request: schoolrooms/computers

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 358, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/base.py", line 261, in execute
    function.__func__(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/schoolldap.py", line 145, in wrapper_func
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/schoolrooms/__init__.py", line 66, in computers
    } for x in SchoolComputer.get_all(ldap_user_read, request.options['school'], pattern)]
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 818, in get_all
    ret.append(cls.from_udm_obj(udm_obj, school, lo))
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 323, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 869, in from_udm_obj
    return klass.from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/computer.py", line 323, in from_udm_obj
    obj = super(SchoolComputer, cls).from_udm_obj(udm_obj, school, lo)
  File "/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.py", line 876, in from_udm_obj
    udm_value = udm_obj[attr.udm_name]
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 478, in __getitem__
    elif key not in self.__no_default and self.descriptions[key].editable:
KeyError: 'ucsschoolRole'

Affected are all systems that upgraded from an UCS@school version <=4.4v1 to >=4.4v1 in the time between 2019-09-11 and 2019-11-27.

The update for Bug #50349 that was released on 2019-11-27 fixes the regression. If you are affected please run the migration script again. You can use the following command to run the migration for the computers of all schools:

$ /usr/share/ucs-school-import/scripts/migrate_ucsschool_roles --computers-school --modify
Mastodon