Skip to content

Commit

Permalink
Merge pull request os-autoinst#18739 from Martchus/fix-mm-network
Browse files Browse the repository at this point in the history
Fix configuring static IP after 40b811b
  • Loading branch information
okurz authored Feb 26, 2024
2 parents 56b461d + 5d19b7d commit 23ef35c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/mm_network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ sub configure_static_ip {
my $ip = $args{ip};
my $mtu = $args{mtu} // get_var('MM_MTU', 1380);
my $is_nm = $args{is_nm} // is_networkmanager();
my $device = $args{device} // '\S';
my $device = $args{device};

if ($is_nm) {
my $nm_id;
$device //= '\S';
my $nm_list = script_output("nmcli -t -f DEVICE,NAME c | grep -v '^lo:' | grep -e '$device' | head -n1");
($device, $nm_id) = split(':', $nm_list);

Expand All @@ -74,7 +75,7 @@ sub configure_static_ip {
my $mac = $net_conf->{fixed}->{mac};

# Get default network adapter name
$device = script_output("grep $mac /sys/class/net/*/address |cut -d / -f 5") unless ($device);
$device ||= script_output("grep $mac /sys/class/net/*/address |cut -d / -f 5");
record_info('set_ip', "Device: $device\nIP: $ip\nMTU: $mtu");

# check for duplicate IP
Expand Down

0 comments on commit 23ef35c

Please sign in to comment.