From a014eeea69a499eff02183cc41e636d9c1313472 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 5 Dec 2025 13:36:56 -0800 Subject: [PATCH] Tweak nmcli connection name discovery This seems to be going wrong quite often in the remote desktop client test - we're getting 'lo' and trying to do a static config on the loopback interface, which clearly isn't going to work. This should either fix it or at least give us some idea why it's going wrong (maybe we don't have any ethernet connections?) Signed-off-by: Adam Williamson --- lib/tapnet.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tapnet.pm b/lib/tapnet.pm index 0dfdd225..bb71742b 100644 --- a/lib/tapnet.pm +++ b/lib/tapnet.pm @@ -45,9 +45,15 @@ sub setup_tap_static { my @dns = get_host_dns(); my $dnstext = 'ipv4.dns "' . join(", ", @dns) . '"'; # bring up network - # this gets us the name of the first connection in the list, - # which should be what we want - my $connection = script_output "nmcli --fields NAME con show | head -2 | tail -1"; + # this gets us the name of the first ethernet-type connection + # in the list, which should be what we want + my $connection = script_output 'nmcli -t --fields NAME,TYPE con show | grep ethernet$ | head -1 | cut -d":" -f1'; + unless ($connection) { + # oh noes, something went hideously wrong! let's do this to + # help figure out what + script_run "nmcli --fields NAME,TYPE con show"; + die "nmcli connection discovery failed!"; + } assert_script_run "nmcli con mod '$connection' ipv4.method manual ipv4.addr $ip/24 ipv4.gateway 172.16.2.2 $dnstext"; assert_script_run "nmcli con down '$connection'"; assert_script_run "nmcli con up '$connection'";