From 379add164261c9b7f59bb269dba4c53fd423f654 Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Sat, 22 Feb 2025 23:22:32 +0100 Subject: [PATCH 1/2] USHIFT-5402: Handle DUID in ipv6 test harness --- .../kickstart-templates/includes/post-network.cfg | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/kickstart-templates/includes/post-network.cfg b/test/kickstart-templates/includes/post-network.cfg index c50311cbf9..23fbc4a1fc 100644 --- a/test/kickstart-templates/includes/post-network.cfg +++ b/test/kickstart-templates/includes/post-network.cfg @@ -17,3 +17,18 @@ find /etc/NetworkManager -name '*.nmconnection' -print0 | while IFS= read -r -d sed -i 's/method=.*/method=auto/g' "${file}" fi done + +# IPv6 only feature. An IPv6 VM will use DHCPv6 to get an IP address. To identify itself to a DHCP +# server it uses something called DHCP Unique Identifier (DUID), and based on that the DHCP server +# will issue a lease for that DUID and MAC address. When the system boots into anaconda to install +# the OS with kickstart files, the DUID is automatically generated. After the system boots into the +# OS a new DUID may be generated, causing DHCP to identify the VM as a new system, thus allocating +# a new IP address. In order to avoid this, the DUID generated during the installarion is saved and +# configured in NetworkManager to use it when the system boots into the OS. +# The DUID is extracted from the journal logs to avoid pinning to a specific NIC name (which would +# use nmcli commands). +DUID=$(journalctl -u NetworkManager | grep duid | grep -Eo "([0-9a-f]{2}:){17}[0-9a-f]{2}" | uniq) +if [ -n "$DUID" ]; then + mkdir -p /etc/NetworkManager/conf.d/ + echo -e "[connection]\nipv6.dhcp-duid=$DUID" > /etc/NetworkManager/conf.d/dhcp-client.conf +fi From 69dd524b22043b8431b82a75cc549ae22df3163f Mon Sep 17 00:00:00 2001 From: Pablo Acevedo Montserrat Date: Mon, 24 Feb 2025 12:13:08 +0100 Subject: [PATCH 2/2] USHIFT-5402: Use nmcli instead of log parsing --- test/kickstart-templates/includes/post-network.cfg | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/kickstart-templates/includes/post-network.cfg b/test/kickstart-templates/includes/post-network.cfg index 23fbc4a1fc..21e98908f2 100644 --- a/test/kickstart-templates/includes/post-network.cfg +++ b/test/kickstart-templates/includes/post-network.cfg @@ -23,11 +23,17 @@ done # will issue a lease for that DUID and MAC address. When the system boots into anaconda to install # the OS with kickstart files, the DUID is automatically generated. After the system boots into the # OS a new DUID may be generated, causing DHCP to identify the VM as a new system, thus allocating -# a new IP address. In order to avoid this, the DUID generated during the installarion is saved and +# a new IP address. In order to avoid this, the DUID generated during the installation is saved and # configured in NetworkManager to use it when the system boots into the OS. -# The DUID is extracted from the journal logs to avoid pinning to a specific NIC name (which would -# use nmcli commands). -DUID=$(journalctl -u NetworkManager | grep duid | grep -Eo "([0-9a-f]{2}:){17}[0-9a-f]{2}" | uniq) +# The DUID is unique per host, and is extracted from the DHCP6 options of the active connections +# from NetworkManager. +DUID=$(nmcli con show --active | \ + awk '{print $1}' | \ + grep -v NAME | \ + xargs nmcli --fields DHCP6.OPTION con show | \ + grep dhcp6_client_id | \ + awk '{print $4}' | \ + uniq) if [ -n "$DUID" ]; then mkdir -p /etc/NetworkManager/conf.d/ echo -e "[connection]\nipv6.dhcp-duid=$DUID" > /etc/NetworkManager/conf.d/dhcp-client.conf