Univention Bugzilla – Bug 34727
Import scripts should not create OUs / other missing objects automatically
Last modified: 2017-12-21 12:23:03 CET
From Bug 26137: > Es sollte geprüft werden, ob das Erstellen einer OU zwingend die Angabe > des/der Slave-Namen voraussetzen kann. Das würde bedeuten, dass es nicht > mehr möglich ist, automatisch/implizit eine OU z.B. durch das Anlegen eines > Users zu erstellen. The import scripts should not create a missing OUs automatically but should stop if a required object is missing.
Needs to be discussed.
*** Bug 27067 has been marked as a duplicate of this bug. ***
Created attachment 9174 [details] patch
The patch has been applied. No schools are created anymore implicit by all the import scripts. ucs-school-import (15.0.3-1) ed80472edd20 | Bug #34727: Merge branch 'fbest/34727-no-automatic-ou-creation' into 4.2 29d4148265fc | Bug #34727: the import scripts do not create missing OUs automatically anymore ucs-school-import.yaml ed80472edd20 | Bug #34727: Merge branch 'fbest/34727-no-automatic-ou-creation' into 4.2 e1901bdbd985 | YAML Bug #34727
OK: manual tests: $ /usr/share/ucs-school-import/scripts/ucs-school-create-dummy-users NotExistentSchool > /tmp/bad_import.csv $ /usr/share/ucs-school-import/scripts/ucs-school-import /tmp/bad_import.csv ----------------------------------------------------------------------- Processing line 268: A G.lehmann1 Lehmann Gabriele NotExistentSchool NotExistentSchool-3B,NotExistentSchool-3C,NotExistentSchool-4B,NotExistentSchool-4r,NotExistentSchool-Froesche,NotExistentSchool-Igel,NotExistentSchool-1A,NotExistentSchool-1B,NotExistentSchool-2A,NotExistentSchool-2B G.lehmann1@uni.dtr 11 0 ERROR: There were problems creating this user: uid=g.lehmann1,cn=lehrer,cn=users,ou=NotExistentSchool,dc=uni,dc=dtr Traceback (most recent call last): File "/usr/share/ucs-school-import/scripts/ucs-school-import", line 1637, in import_user result = create_user(person, baseDN, user_module, passwd, OUT, line) File "/usr/share/ucs-school-import/scripts/ucs-school-import", line 1485, in create_user verify_school_ou(person.sNr, co, lo, baseDN) File "/usr/share/ucs-school-import/scripts/ucs-school-import", line 502, in verify_school_ou raise SystemExit('ERROR: The specified school %r does not exist.' % (schoolNr,)) SystemExit: ERROR: The specified school 'NotExistentSchool' does not exist. ----------------------------------------------------------------------- Not this bug, but just verifying that the new [legacy] import handles this the same way: $ /usr/share/ucs-school-import/scripts/import_user /tmp/bad_import.csv $ /usr/share/ucs-school-import/scripts/ucs-school-testuser-import --staff 2 --verbose NotExistentSchool Both: ----------------------------------------------------------------------- [..] Entry #2: School 'NotExistentSchool' does not exist. Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 143, in create_and_modify_users success = user.create(lo=self.connection) File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 204, in create self.check_schools(lo) File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 200, in check_schools raise UnkownSchoolName('School {!r} does not exist.'.format(school), input=self.input_data, entry_count=self.entry_count, import_user=self) UnkownSchoolName: School 'NotExistentSchool' does not exist.
Please reply to comments in Gitlab: https://git.knut.univention.de/univention/ucsschool/commit/29d4148265fc0c8282aae860b74e27e868d692ea#note_475 https://git.knut.univention.de/univention/ucsschool/commit/e1901bdbd98580b47faf9fe0cdc1fdb2410b014f#note_476
Your QA did only include the import-user script, which is obsolete and must not be used by customers anymore. We have a replacement for this. The problem is about the scripts import_group, import_computer, import_router, import_networks, create_dc, move_domaincontroller_to_ou, export_computer, set_ou_sharefileserver. I added an explicit check for every of these scripts in: ucs-school-import (15.0.3-2) e885a25761e4 | Bug #34727: make sure all import scripts are explicit affected (In reply to Daniel Tröder from comment #6) > Please reply to comments in Gitlab: > https://git.knut.univention.de/univention/ucsschool/commit/ > 29d4148265fc0c8282aae860b74e27e868d692ea#note_475 I think everything is fine here. The functions themself do it like this by calling sys.exit(1). It's not designed to be a library and we have plans to rewrite it. Only the import-user script makes a try:-except: for all other scripts this is working fine. > https://git.knut.univention.de/univention/ucsschool/commit/ > e1901bdbd98580b47faf9fe0cdc1fdb2410b014f#note_476 I added the YAML version number.
OK: advisory OK: manual tests with faulty input: ---------------------------------------------------------------------------- root@m150:~# cd /usr/share/ucs-school-import/scripts # ./create_dc --ou NoSchool --name newdc --type educational ERROR: The specified school 'NoSchool' does not exist. # ./export_computer NoSchool /tmp/computerexport.csv ERROR: The specified school 'NoSchool' does not exist. # ./import_computer ~/computer_import.csv infile is : /root/computer_import.csv Processing line 1: domaincontroller_slave slavename 52:54:00:e3:a7:6d NoSchool 10.11.12.13/24 11,12,13,14 edukativ ERROR: The specified school 'NoSchool' does not exist. # cat ~/network_group.csv A NoSchool newclass A new class. # ./import_group ~/network_group.csv infile is : /root/network_group.csv ERROR: The specified school 'NoSchool' does not exist. # cat ~/network_import.csv NoSchool 10.0.0.0/8 10.0.0.1-10.254.254.250 10.254.254.254 10.254.254.253 10.254.254.252 # ./import_networks ~/network_import.csv infile is : /root/network_import.csv ERROR: The specified school 'NoSchool' does not exist. # cat ~/printer_import.csv A NoSchool spool.uni.dtr PrinterName socket://10.20.30.40.:9000/ HP DeskJet 9000 # ./import_printer ~/printer_import.csv infile is : /root/printer_import.csv ERROR: The specified school 'NoSchool' does not exist. # ./import_router ~/network_import.csv infile is : /root/network_import.csv ERROR: The specified school 'NoSchool' does not exist. "import_user" was tested before and its code has not been modifed. # ./move_domaincontroller_to_ou --dcname $(hostname -s) --ou NoSchool ERROR: The specified school 'NoSchool' does not exist. # ./set_ou_sharefileserver NoSchool m150 ERROR: The specified school 'NoSchool' does not exist. ---------------------------------------------------------------------------- OK: manual tests with correct input: ---------------------------------------------------------------------------- # ./create_ou NewSchool1 && echo "OK" OK # ./create_dc --ou NewSchool1 --name newdc --type educational && echo OK creating object cn=newdc,cn=dc,cn=server,cn=computers,ou=NewSchool1,dc=uni,dc=dtr OK # sed --in-place 's#NoSchool#NewSchool1#g' ~/computer_import.csv # ./import_computer ~/computer_import.csv && echo OK infile is : /root/computer_import.csv Processing line 1: domaincontroller_slave slavename 52:54:00:e3:a7:6d NewSchool1 10.11.12.13/24 11,12,13,14 edukativ generate computer slavename (school NewSchool1) generate network 10.11.12.0/24 creating object zoneName=12.11.10.in-addr.arpa,cn=dns,dc=uni,dc=dtr creating object cn=10.11.12.0,cn=newschool1,cn=dhcp,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newschool1-10.11.12.0,cn=networks,ou=NewSchool1,dc=uni,dc=dtr set ip to 10.11.12.13 is not net 10.11.12.0 creating object cn=slavename,cn=computers,ou=NewSchool1,dc=uni,dc=dtr Processing of line 1 completed OK # ./create_dc --ou NewSchool1 --name newdc --type educational && echo OK OK # ./export_computer NewSchool1 /tmp/computerexport.csv && echo OK outfile is : /tmp/computerexport.csv looking for objects... please wait... writing data of 2 objects... root@m150:/usr/share/ucs-school-import/scripts# cat /tmp/computerexport.csv newdc NewSchool1 slavename NewSchool1 11 10.11.12.13 52:54:00:e3:a7:6d OK # sed --in-place 's#NoSchool#NewSchool1#g' ~/group_import.csv # ./import_group ~/group_import.csv && echo OK infile is : /root/group_import.csv need to create group cn=newclass,cn=klassen,cn=schueler,cn=groups,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newclass,cn=klassen,cn=schueler,cn=groups,ou=NewSchool1,dc=uni,dc=dtr Changed Description of cn=newclass,cn=klassen,cn=schueler,cn=groups,ou=NewSchool1,dc=uni,dc=dtr from to A new class. need to create groupshare cn=newclass,cn=klassen,cn=shares,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newclass,cn=klassen,cn=shares,ou=NewSchool1,dc=uni,dc=dtr OK # sed --in-place 's#NoSchool#NewSchool1#g' ~/network_import.csv # ./import_networks ~/network_import.csv && echo OK infile is : /root/network_import.csv generate network 10.0.0.0/8 iprange: 10.0.0.1-10.254.254.250 defaultrouter: 10.254.254.254 nameserver: 10.254.254.253 netbiosserver: 10.254.254.252 creating object zoneName=10.in-addr.arpa,cn=dns,dc=uni,dc=dtr creating object cn=10.0.0.0,cn=newschool1,cn=dhcp,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newschool1-10.0.0.0,cn=networks,ou=NewSchool1,dc=uni,dc=dtr setting default router need to create container cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr need to create container cn=routing,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=routing,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newschool1-10.0.0.0,cn=routing,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr connecting dhcp subnet (cn=10.0.0.0,cn=newschool1,cn=dhcp,ou=NewSchool1,dc=uni,dc=dtr) with policy (cn=newschool1-10.0.0.0,cn=routing,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr) setting netbios server need to create container cn=netbios,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=netbios,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newschool1-10.0.0.0,cn=netbios,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr connecting dhcp subnet (cn=10.0.0.0,cn=newschool1,cn=dhcp,ou=NewSchool1,dc=uni,dc=dtr) with policy (cn=newschool1-10.0.0.0,cn=netbios,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr) setting nameserver need to create container cn=dns,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=dns,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr creating object cn=newschool1-10.0.0.0,cn=dns,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr connecting dhcp subnet (cn=10.0.0.0,cn=newschool1,cn=dhcp,ou=NewSchool1,dc=uni,dc=dtr) with policy (cn=newschool1-10.0.0.0,cn=dns,cn=dhcp,cn=policies,ou=NewSchool1,dc=uni,dc=dtr) OK # sed --in-place 's#NoSchool#NewSchool1#g' ~/printer_import.csv # ./import_printer ~/printer_import.csv && echo OK infile is : /root/printer_import.csv creating object cn=PrinterName,cn=printers,ou=NewSchool1,dc=uni,dc=dtr OK # ./import_router ~/network_import.csv && echo OK infile is : /root/network_import.csv Router set for subnet. OK # ./move_domaincontroller_to_ou --dcname newdc --ou NewSchool1 && echo OK domaincontroller slave "newdc" is already located below ou "NewSchool1" - stopping here OK # ./set_ou_sharefileserver NewSchool1 newdc && echo OK OK
UCS@school 4.2 v6 has been released. http://docs.software-univention.de/changelog-ucsschool-4.2v6-de.html If this error occurs again, please clone this bug.