[Merge] ~slyon/network-manager:netplan-integration into network-manager:ubuntu/master

Danilo Egea Gondolfo mp+423735 at code.launchpad.net
Wed May 3 14:12:33 UTC 2023


Review: Needs Fixing

Left one comment inline about the migration script.

Diff comments:

> diff --git a/debian/network-manager.postinst b/debian/network-manager.postinst
> index e2cb049..743554a 100644
> --- a/debian/network-manager.postinst
> +++ b/debian/network-manager.postinst
> @@ -81,3 +81,27 @@ esac
>  
>  #DEBHELPER#
>  
> +# Run "Netplan Everywhere" migration after debhelper (re-)started
> +# NetworkManager.service for us. On every package upgrade.
> +DIR="/etc/NetworkManager/system-connections"
> +if [ "$1" = "configure" ] && [ -d "$DIR" ]; then
> +    for CON in /etc/NetworkManager/system-connections/*; do
> +        TYPE=$(file -b "$CON")
> +        [ "$TYPE" = "ASCII text" ] || continue # skip non-keyfiles

It's not guaranteed that the keyfile will be a plain ASCII file. "file -b" returned "Unicode text, UTF-8 text" for one of my keyfiles so it wasn't migrated.

Maybe "file -bi" would be more appropriate? It will return:
"text/plain; charset=us-ascii" and "text/plain; charset=utf-8"

and then we split it and check if the first part if "text/plain".

> +        UUID=$(grep "^uuid=" "$CON" | cut -c 6-)
> +        if [ -n "$UUID" ]
> +        then
> +            ORIG_NAME=$(nmcli --get-values connection.id con show "$UUID")
> +            echo "Migrating $ORIG_NAME ($UUID) to /etc/netplan" 1>&2
> +            # 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.
> +            nmcli con mod "$UUID" con-name "$ORIG_NAME".NETPLAN_MIGRATE
> +            nmcli con mod "$UUID" con-name "$ORIG_NAME"
> +       fi
> +    done
> +    nmcli con reload
> +fi


-- 
https://code.launchpad.net/~slyon/network-manager/+git/network-manager/+merge/423735
Your team Network-manager is requested to review the proposed merge of ~slyon/network-manager:netplan-integration into network-manager:ubuntu/master.




More information about the Ubuntu-reviews mailing list