Mapped each interface name in match.interface-name to a UUID lookup.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 8 months ago
parent 7925a3f42c
commit 6d121dc0c0
  1. 12
      Anvil/Tools/Network.pm
  2. 21
      Anvil/Tools/Striker.pm
  3. 19
      tools/anvil-configure-host

@ -665,6 +665,18 @@ sub collect_data
"nmcli::uuid::${uuid}::${variable}" => $anvil->data->{nmcli}{uuid}{$uuid}{$variable},
}});
if ($variable eq "match.interface-name")
{
# Make sure we can look up the nmcli UUID by any of the names.
foreach my $interface (split/,/, $value)
{
$anvil->data->{nmcli}{interface}{$interface}{uuid} = $uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"nmcli::interface::${interface}::uuid" => $anvil->data->{nmcli}{interface}{$interface}{uuid},
}});
}
}
if ($variable =~ /IP(\d).ADDRESS\[(\d+)\]/)
{
my $ip_type = $1;

@ -341,13 +341,13 @@ sub generate_manifest
my $debug = $parameter->{debug} // 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->generate_manifest()" }});
my $network_dns = $parameter->{dns} // $anvil->data->{cgi}{dns}{value};
my $domain = $parameter->{domain} // $anvil->data->{cgi}{domain}{value};
my $manifest_uuid = $parameter->{manifest_uuid} // $anvil->data->{cgi}{manifest_uuid}{value};
my $network_mtu = $parameter->{mtu} // $anvil->data->{cgi}{mtu}{value};
my $network_ntp = $parameter->{ntp} // $anvil->data->{cgi}{ntp}{value};
my $name_prefix = $parameter->{prefix} // $anvil->data->{cgi}{prefix}{value};
my $padded_sequence = $parameter->{sequence} // $anvil->data->{cgi}{sequence}{value};
my $network_dns = $parameter->{dns} // "";
my $domain = $parameter->{domain} // "";
my $manifest_uuid = $parameter->{manifest_uuid} // "";
my $network_mtu = $parameter->{mtu} // "";
my $network_ntp = $parameter->{ntp} // "";
my $name_prefix = $parameter->{prefix} // "";
my $padded_sequence = $parameter->{sequence} // "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
network_dns => $network_dns,
domain => $domain,
@ -379,6 +379,13 @@ sub generate_manifest
$anvil->Database->get_upses({debug => $debug});
$anvil->Database->get_fences({debug => $debug});
if (not $manifest_uuid)
{
# Don't proceed, we'd get an invalid manifest.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "warning_0159"});
return('!!error!!');
}
if ($manifest_uuid eq "new")
{
$manifest_uuid = "";

@ -507,7 +507,7 @@ ORDER BY
$anvil->data->{sys}{reboot} = 0;
# Read the existing network data
$anvil->Network->collect_data({start => 1});
$anvil->Network->collect_data({debug => 2, start => 1});
# This will be set to '1' if we make a change.
my $changes = 0;
@ -1779,7 +1779,7 @@ sub reconfigure_ip_addresses
line => __LINE__,
variables => { },
});
$anvil->Network->collect_data();
$anvil->Network->collect_data({debug => 2});
}
}
@ -1843,7 +1843,7 @@ sub reconfigure_interfaces
line => __LINE__,
variables => { },
});
$anvil->Network->collect_data();
$anvil->Network->collect_data({debug => 2});
}
}
}
@ -1925,11 +1925,20 @@ sub reconfigure_interfaces
foreach my $interface (split/,/, $match_interface_name)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface }});
# In case the GENERAL.IP-IFACE or GENERAL.NAME name didn't update,
# map this interface name to 'nmcli::interface::<name>::uuid'.
if (not exists $anvil->data->{nmcli}{interface}{$interface})
{
$anvil->data->{nmcli}{interface}{$interface}{uuid} = $link1_nm_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"nmcli::interface::${interface}::uuid" => $anvil->data->{nmcli}{interface}{$interface}{uuid},
}});
}
if ($interface eq $wanted_link1_name)
{
$found = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { found => $found }});
last;
}
}
if (not $found)
@ -2352,7 +2361,7 @@ sub rename_interface
line => __LINE__,
variables => { },
});
$anvil->Network->collect_data();
$anvil->Network->collect_data({debug => 2});
# Set the reboot flag.
$anvil->data->{sys}{reboot_needed} = 1;

Loading…
Cancel
Save