Bug 52259 - Migrate univention-dhcp to Python 3
Migrate univention-dhcp to Python 3
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: DHCP
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0
Assigned To: Philipp Hahn
Florian Best
:
Depends on:
Blocks: 53074
  Show dependency treegraph
 
Reported: 2020-10-26 23:38 CET by Florian Best
Modified: 2021-05-25 15:59 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
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:


Attachments
dhcpd.conf (3.37 KB, text/plain)
2021-02-17 17:42 CET, Florian Best
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2020-10-26 23:38:27 CET
univention-dhcp should be migrated to be Python 3 compatible.
Comment 1 Philipp Hahn univentionstaff 2020-12-01 14:38:03 CET
import-dhcpd.conf is not part of the shipped package - I converted it nevertheless.

Package: univention-dhcp
Version: 14.0.2-5A~5.0.0.202012011402
Branch: ucs_5.0-0

[5.0-0] a7e5b0b069 Bug #52259 DHCP: Convert to Python 3
 doc/changelog/changelog-5.0-0.xml          |   2 +-
 services/univention-dhcp/debian/changelog  |   1 +
 services/univention-dhcp/dhcp.py           |   2 +
 services/univention-dhcp/import-dhcpd.conf | 190 +++++++++++++++++++++++++++++++------------------
 4 files changed, 123 insertions(+), 72 deletions(-)
Comment 2 Florian Best univentionstaff 2021-02-17 13:05:26 CET
Do you want to convert the joinscript as well? And change the dependency to python3-univention-lib.
Comment 3 Florian Best univentionstaff 2021-02-17 17:42:10 CET
Created attachment 10622 [details]
dhcpd.conf

Traceback (most recent call last):
  File "./import-dhcpd.conf", line 392, in <module>
    sections[depth][4].append((otype, result))
IndexError: list index out of range
Comment 4 Philipp Hahn univentionstaff 2021-02-17 18:34:08 CET
(In reply to Florian Best from comment #3)
>   File "./import-dhcpd.conf", line 392, in <module>
> IndexError: list index out of range

See comment #1:
> import-dhcpd.conf is not part of the shipped package - I converted it nevertheless.

that script is an evil hack and will fail on more examples than succeed. It is not worth fixing until explicitly requested.
In your case is simply does not support "shared-network" in line 92ff.


(In reply to Florian Best from comment #2)
> Do you want to convert the joinscript as well? And change the dependency to
> python3-univention-lib.

[5.0-0] 4359208b7a Bug #52259 dhcp: Convert to Python3
 services/univention-dhcp/25univention-dhcp.inst                 |  74 +-------------------
 services/univention-dhcp/debian/changelog                       |   6 ++
 services/univention-dhcp/debian/univention-dhcp.install         |   6 +-
 services/univention-dhcp/etc/runit/univention-dhcp/run          |  30 ---------
 services/univention-dhcp/import-dhcpd.conf                      |  42 ++++--------
 services/univention-dhcp/usr/lib/univention-dhcp/create-subnets | 101 ++++++++++++++++++++++++++++
 6 files changed, 125 insertions(+), 134 deletions(-)

[5.0-0] d708a7ce49 fixup! Bug #52259 dhcp: Convert to Python3
 services/univention-dhcp/usr/lib/univention-dhcp/create-subnets | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Package: univention-dhcp
Version: 14.0.3-2A~5.0.0.202102171832
Branch: ucs_5.0-0
Comment 5 Philipp Hahn univentionstaff 2021-02-18 08:46:56 CET
(In reply to Florian Best from comment #2)
> And change the dependency to python3-univention-lib.

forgot to change that:

[5.0-0] 4832179d11 Bug #52259 dhcp: Convert to Python 3
 services/univention-dhcp/debian/changelog | 6 ++++++
 services/univention-dhcp/debian/control   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

Bug fixed by @fbest - thanks:

[5.0-0] 070a9a76fb fixup! Bug #52259 dhcp: Convert to Python3
 services/univention-dhcp/usr/lib/univention-dhcp/create-subnets | 1 -
 1 file changed, 1 deletion(-)

Package: univention-dhcp
Version: 14.0.3-3A~5.0.0.202102180747
Branch: ucs_5.0-0

OK: /usr/lib/univention-dhcp/create-subnets --help
OK: S="$(udm dhcp/service list | sed -ne 's/^DN: //p;T;q')"
OK: /usr/lib/univention-dhcp/create-subnets --service "$S"
OK: /usr/lib/univention-dhcp/create-subnets --service "$S" --binddn "$(ucr get ldap/hostdn)" --bindpwdfile /etc/machine.secret
OK: /usr/lib/univention-dhcp/create-subnets --service "$S" --binddn "$(ucr get ldap/hostdn)" --bindpwd "$(</etc/machine.secret)"
OK: P="$(udm policies/dhcp_dns list | sed -ne 's/^DN: //p;T;q')"
OK: /usr/lib/univention-dhcp/create-subnets --service "$S" --policy-reference "$P"
Comment 6 Florian Best univentionstaff 2021-02-19 21:31:19 CET
OK
Comment 7 Philipp Hahn univentionstaff 2021-02-20 13:49:15 CET
FYI: During my update from 4.4-7+e898 to 5.0-0~2021-02-20 univention-dhcp failed the upgrade:

From /var/log/univention/updater.log

univention-dhcp (14.0.3-3A~5.0.0.202102180747) wird eingerichtet ...
...
2021-02-20 11:50:06.699634985+01:00 (in joinscript_init)
A system update is currently being performed. The execution of the join script /usr/lib/univention-install/25univention-dhcp.inst is therefore postponed.
isc-dhcp-server.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install is-enabled isc-dhcp-server
univention-firewall.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install is-enabled univention-firewall
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
dpkg: Fehler beim Bearbeiten des Paketes univention-dhcp (--configure):
 »installiertes univention-dhcp-Skript des Paketes post-installation«-Unterprozess gab den Fehlerwert 1 zurück

/var/log/daemon.log only has:

Feb 20 11:53:21 m34 dhcpd[5405]: Configuration file errors encountered -- exiting
Comment 8 Florian Best univentionstaff 2021-05-25 15:59:05 CEST
UCS 5.0 has been released:
 https://docs.software-univention.de/release-notes-5.0-0-en.html
 https://docs.software-univention.de/release-notes-5.0-0-de.html

If this error occurs again, please use "Clone This Bug".