Univention Bugzilla – Bug 55014
import_computer does not pass additional colums to computer hooks
Last modified: 2023-01-20 10:06:52 CET
The old "import_computer" import script of UCS@school 4.4 passed the CSV import line to the shell script hooks, so that they could extract additional information. When the script has been converted to use pyhooks only, this ability has not been implemented. From the old "import_computer": # invoke pre hooks hooks.pre("computer", "A", line=line) ... # invoke post hooks if success: hooks.post("computer", "A", dn=object.dn, line=line) The pyhook only gets e.g. the actual WindowsComputer object but not the CSV line.
$ cat computers.csv windows winDMEOSCHOOL-02 10:00:ee:ff:cc:03 DEMOSCHOOL 10.0.5.5 inventar 10:00:ee:ff:cc:04 $ cat /usr/share/ucs-school-import/pyhooks/add_extra_mac.py from ucsschool.lib.models.computer import SchoolComputer from ucsschool.importer.utils.computer_pyhook import ComputerPyHook class AddExtraMacSchoolComputer(ComputerPyHook): model = SchoolComputer priority = { "pre_create": 10, } def pre_create(self, obj, line): obj.mac_address.append(line[-1]) $ /usr/share/ucs-school-import/scripts/import_computer computers.csv $ udm computers/windows list | grep mac mac: 10:00:ee:ff:cc:03 mac: 10:00:ee:ff:cc:04
* [x] OK: Code review * [x] OK: merge * [x] OK: package update * [x] OK: documentation * [x] OK: advisory * [x] OK: automated tests (interactively and in Jenkins)
docu: https://docs.software-univention.de/ucsschool-manual/5.0/de/manage-school-imports.html#skriptbasierter-import-von-pcs ... Errata updates for UCS@school 5.0 v3 have been released. https://docs.software-univention.de/ucsschool-changelog/5.0v3/de/changelog.html If this error occurs again, please clone this bug.