Skip to content

Commit 69dd524

Browse files
committed
USHIFT-5402: Use nmcli instead of log parsing
1 parent 379add1 commit 69dd524

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/kickstart-templates/includes/post-network.cfg

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ done
2323
# will issue a lease for that DUID and MAC address. When the system boots into anaconda to install
2424
# the OS with kickstart files, the DUID is automatically generated. After the system boots into the
2525
# OS a new DUID may be generated, causing DHCP to identify the VM as a new system, thus allocating
26-
# a new IP address. In order to avoid this, the DUID generated during the installarion is saved and
26+
# a new IP address. In order to avoid this, the DUID generated during the installation is saved and
2727
# configured in NetworkManager to use it when the system boots into the OS.
28-
# The DUID is extracted from the journal logs to avoid pinning to a specific NIC name (which would
29-
# use nmcli commands).
30-
DUID=$(journalctl -u NetworkManager | grep duid | grep -Eo "([0-9a-f]{2}:){17}[0-9a-f]{2}" | uniq)
28+
# The DUID is unique per host, and is extracted from the DHCP6 options of the active connections
29+
# from NetworkManager.
30+
DUID=$(nmcli con show --active | \
31+
awk '{print $1}' | \
32+
grep -v NAME | \
33+
xargs nmcli --fields DHCP6.OPTION con show | \
34+
grep dhcp6_client_id | \
35+
awk '{print $4}' | \
36+
uniq)
3137
if [ -n "$DUID" ]; then
3238
mkdir -p /etc/NetworkManager/conf.d/
3339
echo -e "[connection]\nipv6.dhcp-duid=$DUID" > /etc/NetworkManager/conf.d/dhcp-client.conf

0 commit comments

Comments
 (0)