Merge ~slyon/network-manager:netplan-migrate-maintscript into network-manager:netplan/lunar-gu

Proposed by Lukas Märdian
Status: Merged
Merged at revision: f9372617a07831a143d32e7f4521499b7c454566
Proposed branch: ~slyon/network-manager:netplan-migrate-maintscript
Merge into: network-manager:netplan/lunar-gu
Diff against target: 35 lines (+27/-0)
1 file modified
debian/network-manager.postinst (+27/-0)
Reviewer Review Type Date Requested Status
Simon Chopin Needs Information
Danilo Egea Gondolfo Pending
Review via email: mp+440401@code.launchpad.net

Description of the change

d/network-manager.postinst: Trigger Netplan migration on install/upgrade

Modify the connection's ID (con-name) to trigger its migration.
The Netplan integration will translate the original NM keyfile from
/etc/NetworkManager/system-connections/* to a YAML file located in
/etc/netplan/90-NM-*.yaml and re-generate a corresponding keyfile in
/run/NetworkManager/system-connections/netplan-NM-*.nmconnection
After successful migration, the original ID (con-name) is restored.

To post a comment you must log in.
Revision history for this message
Simon Chopin (schopin) wrote :

question: What happens to the original keyfile?

If it's not removed, then re-running the script (cf https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#maintainer-scripts-idempotency ) will overwrite the previous migration's yaml, which might have changed in the mean time.

review: Needs Information
Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

The original keyfile in /etc/NetworkManager/system-connections/* is being deleted by the Netplan integration automatically during the process, after it got translated into /etc/netplan/90-NM-*.yaml successfully.

I.e. that would be within the first "nmcli con mod ..." call for each connection profile.

Revision history for this message
Dave Jones (waveform) wrote :

Left a couple of comments on the version comparison line which might bear some thought (but I'm unsure if they're actually relevant without additional context).

Revision history for this message
Lukas Märdian (slyon) :
Revision history for this message
Lukas Märdian (slyon) wrote :

Thanks! Answered Dave's inline comment. I think the current implementation matches my intention.

Revision history for this message
Lukas Märdian (slyon) wrote :

Thanks all! We got some extra eyeballs, let's get this merged and deployed to the "Netplan Everywhere PPA (Lunar)" testers.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/network-manager.postinst b/debian/network-manager.postinst
2index e2cb049..ba31d6b 100644
3--- a/debian/network-manager.postinst
4+++ b/debian/network-manager.postinst
5@@ -81,3 +81,30 @@ esac
6
7 #DEBHELPER#
8
9+# Run "Netplan Everywhere" migration after debhelper (re-)started
10+# NetworkManager.service for us
11+# XXX: Shall we run this migration just on the upgrade to this specific
12+# version, or on any upgrade/install?
13+#if dpkg --compare-versions "$2" lt "1.42.4-1ubuntu3"; then
14+DIR="/etc/NetworkManager/system-connections"
15+if [ "$1" = "configure" ] && [ -d "$DIR" ]; then
16+ for CON in /etc/NetworkManager/system-connections/*; do
17+ TYPE=$(file -b "$CON")
18+ [ "$TYPE" = "ASCII text" ] || continue # skip non-keyfiles
19+ UUID=$(grep "^uuid=" "$CON" | cut -c 6-)
20+ if [ -n "$UUID" ]
21+ then
22+ ORIG_NAME=$(nmcli --get-values connection.id con show "$UUID")
23+ echo "Migrating $ORIG_NAME ($UUID) to /etc/netplan" 1>&2
24+ # Modify the connection's ID (con-name) to trigger its migration.
25+ # The Netplan integration will translate the original NM keyfile from
26+ # /etc/NetworkManager/system-connections/* to a YAML file located in
27+ # /etc/netplan/90-NM-*.yaml and re-generate a corresponding keyfile in
28+ # /run/NetworkManager/system-connections/netplan-NM-*.nmconnection
29+ # After successful migration, the original ID (con-name) is restored.
30+ nmcli con mod "$UUID" con-name "$ORIG_NAME".NETPLAN_MIGRATE
31+ nmcli con mod "$UUID" con-name "$ORIG_NAME"
32+ fi
33+ done
34+ nmcli con reload
35+fi

Subscribers

People subscribed via source and target branches

to all changes: