update_nics: Combine post-update host loops

This commit is contained in:
Richard Hansen 2024-08-29 13:20:01 -04:00
parent bf83ba032c
commit a178d40633

View file

@ -1460,17 +1460,14 @@ sub update_nics {
$config{$h}{'wantip'} = $config{$h}{'wantipv4'} // $config{$h}{'wantipv6'};
}
&$update(@hosts);
for my $h (@hosts) {
delete($config{$h}{$_}) for qw(wantip wantipv4 wantipv6);
}
# Backwards compatibility: Legacy protocol implementations read `wantip` and set `ip`
# and `status`. Modern protocol implementations read `wantipv4` and `wantipv6` and set
# `ipv4`, `ipv6`, `status-ipv4`, and `status-ipv6`. Make legacy implementations look
# like modern implementations by moving `ip` and `status` to the modern
# version-specific equivalents.
for my $h (@hosts) {
local $_l = pushlogctx($h);
delete($config{$h}{$_}) for qw(wantip wantipv4 wantipv6);
# Backwards compatibility: Legacy protocol implementations read `wantip` and set
# `ip` and `status`. Modern protocol implementations read `wantipv4` and
# `wantipv6` and set `ipv4`, `ipv6`, `status-ipv4`, and `status-ipv6`. Make legacy
# implementations look like modern implementations by moving `ip` and `status` to
# the modern version-specific equivalents.
my $status = delete($config{$h}{'status'}) or next;
my $ip = $config{$h}{'ip'};
my $ipv = is_ipv4($ip) ? '4' : is_ipv6($ip) ? '6' : undef;