Bug 55014 - import_computer does not pass additional colums to computer hooks
import_computer does not pass additional colums to computer hooks
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 5.0
Other Linux
: P5 enhancement (vote)
: UCS@school 5.0 v3-errata
Assigned To: Tobias Wenzel
Daniel Tröder
Depends on:
  Show dependency treegraph
Reported: 2022-07-19 22:12 CEST by Sönke Schwardt-Krummrich
Modified: 2023-01-20 10:06 CET (History)
6 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
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):
Max CVSS v3 score:


Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2022-07-19 22:12:03 CEST
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.
Comment 6 Tobias Wenzel univentionstaff 2023-01-12 12:14:59 CET
$ cat computers.csv 

windows	winDMEOSCHOOL-02	10:00:ee:ff:cc:03	DEMOSCHOOL	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):

$ /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
Comment 7 Daniel Tröder univentionstaff 2023-01-13 11:30:09 CET
* [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)
Comment 8 Tobias Wenzel univentionstaff 2023-01-20 10:06:52 CET
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.


If this error occurs again, please clone this bug.