Bug 55130 - Regression in import_computer: specifying a network instead of specific IP address throws traceback
Regression in import_computer: specifying a network instead of specific IP ad...
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 5.0
Other Linux
: P5 normal (vote)
: UCS@school 5.0 v3-errata
Assigned To: Tobias Wenzel
Ole Schwiegert
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-08-24 15:01 CEST by Sönke Schwardt-Krummrich
Modified: 2022-11-02 14:13 CET (History)
6 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.343
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support: Yes
Flags outvoted (downgraded) after PO Review:
Ticket number: 2022082221000435, 2022090121000535, 2022101821000297, 2022101921000517, 2022102521000587
Bug group (optional): Regression
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2022-08-24 15:01:57 CEST
Starting with UCS@school 5.0v2 the script import_computer of the package 
"ucs-school-import" is no longer able to process network addresses as stated in the UCS@school manual:
https://docs.software-univention.de/ucsschool-handbuch-5.0.html#school:schoolcreate:computers:import

Before you were able to specify a network address, e.g. "10.20.0.0/255.255.248.0", and the script automatically determined the next free IP address in that subnet and assigned it to the computer.

Now the following traceback is returned:

root@master:~# /usr/share/ucs-school-import/scripts/import_computer \
   /root/my_host_list.txt
input file is  : /root/my_host_list.txt
Processing line 1: windows	wsABC-123	AA:BB:CC:DD:EE:FF	ABC	10.200.160.0/255.255.248.0	1234567890
 Traceback (most recent call last):
  File "/usr/share/ucs-school-import/scripts/import_computer", line 179, in <module>
    import_computers(options.inputfile)
  File "/usr/share/ucs-school-import/scripts/import_computer", line 151, in import_computers
    computer.create(lo)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/computer.py", line 295, in create
    return super(SchoolComputer, self).create(lo, validate)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/base.py", line 547, in create
    success = self.create_without_hooks(lo, validate)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/computer.py", line 298, in create_without_hooks
    self.create_network(lo)
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/computer.py", line 335, in create_network
    network = self.get_network()
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/computer.py", line 324, in get_network
    ipv4_network = self.get_ipv4_network()
  File "/usr/lib/python3/dist-packages/ucsschool/lib/models/computer.py", line 307, in get_ipv4_network
    if self.subnet_mask is not None and len(self.ip_address) > 0:
TypeError: object of type 'NoneType' has no len()
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2022-08-24 15:16:34 CEST
An adapted ucs-test script that triggers the problem and a first attempt for a fix has been pushed to git: 
https://git.knut.univention.de/univention/ucsschool/-/merge_requests/145

Please note, that only the test script ./35_import-computers_via_cli.py has been tested yet! Other tests might fail like ./35_import-computers_via_python.py!
Comment 3 Sönke Schwardt-Krummrich univentionstaff 2022-09-05 11:58:41 CEST
(In reply to Sönke Schwardt-Krummrich from comment #1)
> An adapted ucs-test script that triggers the problem and a first attempt for
> a fix has been pushed to git: 
> https://git.knut.univention.de/univention/ucsschool/-/merge_requests/145
> 
> Please note, that only the test script ./35_import-computers_via_cli.py has
> been tested yet! Other tests might fail like
> ./35_import-computers_via_python.py!

The MR makes it possible to import computers again, but import_computer always uses the netmask 255.255.255.0 even if a different netmask like 255.255.248.0 is specified!
Comment 4 Christina Scheinig univentionstaff 2022-10-18 13:27:54 CEST
A customer has created client networks that differ from the standard /24 mask. He is now not able to import new Clients, because even if he gives each client its own IP and specify the subnet, the importer has always created a new network with a /24 mask.
Comment 6 Christina Scheinig univentionstaff 2022-10-20 09:13:59 CEST
Next customer can into this, after upgrade to UCS5.
Specifying the subnet mask of a class B network does not work anymore, so customer with Class B net, cannot import computers anymore.

Import is done but class C networks are created in the network of the OU and in the Dhcp. In DNS, the reverse zones are shared between class C networks.

Examples:
Bsp. Importdatei:

mit Angabe Subnetz ausgeschrieben

windows mstest-vbc-006  90:2b:34:13:6a:4f       ms_test 10.226.15.21/255.255.0.0        1234567         Multimedia PC wir2      serien3456
windows mstest-vbc-004  68:f7:28:1e:6c:7c       ms_test 10.226.15.19/255.255.0.0        3456789         testpctest      seriennr1234

Ausgabe Vi mit set list

windows^Imstest-vbc-006^I90:2b:34:13:6a:4f^Ims_test^I10.226.15.21/255.255.0.0^I1234567^I^IMultimedia PC wir2^Iserien3456$
windows^Imstest-vbc-004^I68:f7:28:1e:6c:7c^Ims_test^I10.226.15.19/255.255.0.0^I3456789^I^Itestpctest^Iseriennr1234$  

mit verkürtzer Schreibweise

windows mstest-vbc-006  90:2b:34:13:6a:4f       ms_test 10.226.15.21/16 1234567         Multimedia PC wir2      serien3456       
windows mstest-vbc-004  68:f7:28:1e:6c:7c       ms_test 10.226.15.19/16 3456789         testpctest      seriennr1234

Ausgabe Vi mit set list
windows^Imstest-vbc-006^I90:2b:34:13:6a:4f^Ims_test^I10.226.15.21/16^I1234567^I^IMultimedia PC wir2^Iserien3456$
windows^Imstest-vbc-004^I68:f7:28:1e:6c:7c^Ims_test^I10.226.15.19/16^I3456789^I^Itestpctest^Iseriennr1234$
Comment 7 Tobias Wenzel univentionstaff 2022-10-27 13:35:32 CEST
The subnet mask had not been passed to the ucs-school-lib computer object.

Thanks for the pre-work to Sönke!

The fix will be released next week (because tomorrow is Friday) and Monday is a public holiday and we want jenkins to pass.


[5.0] 49cd391a7 Bug #55130: advisory fix
[5.0] 94a37223a Bug #55130: changelog + advisories
[5.0] 0e2e2b6ae Bug #55130: pass IP address/subnet to UCS@school lib in any case

Package: ucs-school-import
Version: 18.0.23A~5.0.0.202210271327
Branch: ucs_5.0-0
Scope: ucs-school-5.0

Package: ucs-test-ucsschool
Version: 7.3.76A~5.0.0.202210271330
Branch: ucs_5.0-0
Scope: ucs-school-5.0
Comment 8 Tobias Wenzel univentionstaff 2022-11-02 14:13:34 CET
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.