Reduced logging in anvil-configure-host.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 10 months ago
parent a65bf5090e
commit 25841145b5
  1. 88
      tools/anvil-configure-host

@ -70,7 +70,6 @@ if (($< != 0) && ($> != 0))
# Make sure that we set the network->wait_for_bonds() timeout to 60 seconds. # Make sure that we set the network->wait_for_bonds() timeout to 60 seconds.
$anvil->Storage->update_config({ $anvil->Storage->update_config({
debug => 2,
append => 1, append => 1,
variable => "network::wait_for_bonds::timeout", variable => "network::wait_for_bonds::timeout",
value => 60, value => 60,
@ -83,7 +82,7 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secu
}}); }});
# Connect # Connect
$anvil->Database->connect({debug => 2, check_for_resync => 1}); $anvil->Database->connect({check_for_resync => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "message_0031"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "message_0031"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections}) if (not $anvil->data->{sys}{database}{connections})
@ -104,7 +103,6 @@ reconfigure_network($anvil);
# Record that we've configured this machine. # Record that we've configured this machine.
$anvil->Database->insert_or_update_variables({ $anvil->Database->insert_or_update_variables({
debug => 2,
variable_name => "system::configured", variable_name => "system::configured",
variable_value => 1, variable_value => 1,
variable_default => "", variable_default => "",
@ -123,14 +121,13 @@ $anvil->Job->update_progress({
# Make sure that we set the network->wait_for_bonds() timeout back to 180. # Make sure that we set the network->wait_for_bonds() timeout back to 180.
$anvil->Storage->update_config({ $anvil->Storage->update_config({
debug => 2,
append => 1, append => 1,
variable => "network::wait_for_bonds::timeout", variable => "network::wait_for_bonds::timeout",
value => 180, value => 180,
}); });
# Clear maintenance mode. # Clear maintenance mode.
$anvil->System->maintenance_mode({set => 0, debug => 2}); $anvil->System->maintenance_mode({set => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0467"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0467"});
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
@ -248,12 +245,8 @@ sub update_passwords
my $shell_call = $anvil->data->{path}{exe}{'anvil-change-password'}." -y --password-file ".$temp_file.$anvil->Log->switches; my $shell_call = $anvil->data->{path}{exe}{'anvil-change-password'}." -y --password-file ".$temp_file.$anvil->Log->switches;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => 2, timeout => 15, shell_call => $shell_call }); my ($output, $return_code) = $anvil->System->call({timeout => 15, shell_call => $shell_call });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code }});
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
}
if ($return_code) if ($return_code)
{ {
@ -352,7 +345,7 @@ sub reconfigure_network
} }
# Set the host_name # Set the host_name
my ($host_name, $descriptive_host_name) = $anvil->System->host_name({set => $new_host_name, pretty => $pretty_host_name, debug => 3}); my ($host_name, $descriptive_host_name) = $anvil->System->host_name({set => $new_host_name, pretty => $pretty_host_name});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
host_name => $host_name, host_name => $host_name,
descriptive_host_name => $descriptive_host_name, descriptive_host_name => $descriptive_host_name,
@ -514,7 +507,7 @@ ORDER BY
$anvil->data->{sys}{reboot} = 0; $anvil->data->{sys}{reboot} = 0;
# Read the existing network data # Read the existing network data
$anvil->Network->collect_data({debug => 2, start => 1}); $anvil->Network->collect_data({start => 1});
# This will be set to '1' if we make a change. # This will be set to '1' if we make a change.
my $changes = 0; my $changes = 0;
@ -541,7 +534,7 @@ ORDER BY
file => $THIS_FILE, file => $THIS_FILE,
line => __LINE__, line => __LINE__,
}); });
$anvil->Database->disconnect({debug => 2}); $anvil->Database->disconnect();
} }
# These can brake the connection. # These can brake the connection.
@ -562,7 +555,7 @@ ORDER BY
while ($waiting) while ($waiting)
{ {
$anvil->refresh(); $anvil->refresh();
$anvil->Database->connect({debug => 2}); $anvil->Database->connect();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::database::connections" => $anvil->data->{sys}{database}{connections} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::database::connections" => $anvil->data->{sys}{database}{connections} }});
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
@ -606,8 +599,11 @@ ORDER BY
} }
# If any virtio bridges exist, remove it/them. # If any virtio bridges exist, remove it/them.
my $start = 0; my $start = 0;
my ($bridges, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{setsid}." --wait ".$anvil->data->{path}{exe}{virsh}." net-list"}); my $shell_call = $anvil->data->{path}{exe}{setsid}." --wait ".$anvil->data->{path}{exe}{virsh}." net-list";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($bridges, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridges => $bridges, return_code => $return_code }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridges => $bridges, return_code => $return_code }});
if ($return_code) if ($return_code)
{ {
@ -764,7 +760,7 @@ sub reconfigure_bridges
else else
{ {
# If there are ifcfg files for this bridge, move it. # If there are ifcfg files for this bridge, move it.
my $network_type = $anvil->System->check_network_type({debug => 2}); my $network_type = $anvil->System->check_network_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }});
if ($network_type eq "ifcfg") if ($network_type eq "ifcfg")
{ {
@ -783,7 +779,7 @@ sub reconfigure_bridges
job_uuid => $anvil->data->{job}{uuid}, job_uuid => $anvil->data->{job}{uuid},
variables => { file => $ifcfg_file }, variables => { file => $ifcfg_file },
}); });
$anvil->Storage->backup({debug => 2, file => $ifcfg_file}); $anvil->Storage->backup({file => $ifcfg_file});
unlink $ifcfg_file; unlink $ifcfg_file;
} }
} }
@ -835,8 +831,8 @@ sub reconfigure_bridges
device_uuid => $bridge_uuid, device_uuid => $bridge_uuid,
}, },
}); });
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $bridge_uuid, variable => "ipv4.method", value => "disabled"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $bridge_uuid, variable => "ipv4.method", value => "disabled"});
($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $bridge_uuid, variable => "ipv6.method", value => "disabled"}); ($output, $return_code) = $anvil->Network->modify_connection({uuid => $bridge_uuid, variable => "ipv6.method", value => "disabled"});
my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection up ".$bridge_name; my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection up ".$bridge_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
@ -858,7 +854,7 @@ sub reconfigure_bridges
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
# Checking that the device is connected to this bridge # Checking that the device is connected to this bridge
@ -944,8 +940,8 @@ sub reconfigure_bridges
device_uuid => $on_device_uuid, device_uuid => $on_device_uuid,
}, },
}); });
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $on_device_uuid, variable => "ipv4.method", value => "disabled"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $on_device_uuid, variable => "ipv4.method", value => "disabled"});
($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $on_device_uuid, variable => "ipv6.method", value => "disabled"}); ($output, $return_code) = $anvil->Network->modify_connection({uuid => $on_device_uuid, variable => "ipv6.method", value => "disabled"});
# Connect it now. # Connect it now.
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -1000,7 +996,7 @@ sub reconfigure_bridges
device_uuid => $on_device_uuid, device_uuid => $on_device_uuid,
}, },
}); });
($output, $return_code) = $anvil->Network->reset_connection({debug => 2, uuid => $on_device_uuid}); ($output, $return_code) = $anvil->Network->reset_connection({uuid => $on_device_uuid});
# Rescan. # Rescan.
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -1013,7 +1009,7 @@ sub reconfigure_bridges
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
} }
@ -1139,7 +1135,7 @@ sub reconfigure_bonds
}); });
# If there are ifcfg files for this bond, move it. # If there are ifcfg files for this bond, move it.
my $network_type = $anvil->System->check_network_type({debug => 2}); my $network_type = $anvil->System->check_network_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }});
if ($network_type eq "ifcfg") if ($network_type eq "ifcfg")
{ {
@ -1158,7 +1154,7 @@ sub reconfigure_bonds
job_uuid => $anvil->data->{job}{uuid}, job_uuid => $anvil->data->{job}{uuid},
variables => { file => $ifcfg_file }, variables => { file => $ifcfg_file },
}); });
$anvil->Storage->backup({debug => 2, file => $ifcfg_file}); $anvil->Storage->backup({file => $ifcfg_file});
unlink $ifcfg_file; unlink $ifcfg_file;
} }
} }
@ -1209,8 +1205,8 @@ sub reconfigure_bonds
device_uuid => $bond_uuid, device_uuid => $bond_uuid,
}, },
}); });
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $bond_uuid, variable => "ipv4.method", value => "disabled"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $bond_uuid, variable => "ipv4.method", value => "disabled"});
($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $bond_uuid, variable => "ipv6.method", value => "disabled"}); ($output, $return_code) = $anvil->Network->modify_connection({uuid => $bond_uuid, variable => "ipv6.method", value => "disabled"});
my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection up ".$bond_name; my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection up ".$bond_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
@ -1231,7 +1227,7 @@ sub reconfigure_bonds
file => $THIS_FILE, file => $THIS_FILE,
line => __LINE__, line => __LINE__,
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
# Now add the interfaces, disabling their ipv4.method first. # Now add the interfaces, disabling their ipv4.method first.
@ -1328,8 +1324,8 @@ sub reconfigure_bonds
device_uuid => $nm_uuid, device_uuid => $nm_uuid,
}, },
}); });
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $nm_uuid, variable => "ipv4.method", value => "disabled"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $nm_uuid, variable => "ipv4.method", value => "disabled"});
($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $nm_uuid, variable => "ipv6.method", value => "disabled"}); ($output, $return_code) = $anvil->Network->modify_connection({uuid => $nm_uuid, variable => "ipv6.method", value => "disabled"});
# Connecting the interface to the bond # Connecting the interface to the bond
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -1387,7 +1383,7 @@ sub reconfigure_bonds
device_uuid => $nm_uuid, device_uuid => $nm_uuid,
}, },
}); });
($output, $return_code) = $anvil->Network->reset_connection({debug => 2, uuid => $nm_uuid}); ($output, $return_code) = $anvil->Network->reset_connection({uuid => $nm_uuid});
# Rescan. # Rescan.
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -1400,7 +1396,7 @@ sub reconfigure_bonds
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
} }
} }
@ -1716,8 +1712,8 @@ sub reconfigure_ip_addresses
device_uuid => $old_uuid, device_uuid => $old_uuid,
}, },
}); });
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $old_uuid, variable => "ipv4.method", value => "disabled"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $old_uuid, variable => "ipv4.method", value => "disabled"});
($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $old_uuid, variable => "ipv6.method", value => "disabled"}); ($output, $return_code) = $anvil->Network->modify_connection({uuid => $old_uuid, variable => "ipv6.method", value => "disabled"});
$anvil->Job->update_progress({ $anvil->Job->update_progress({
progress => $anvil->Job->bump_progress({steps => 1}), progress => $anvil->Job->bump_progress({steps => 1}),
@ -1732,7 +1728,7 @@ sub reconfigure_ip_addresses
device_uuid => $old_uuid, device_uuid => $old_uuid,
}, },
}); });
($output, $return_code) = $anvil->Network->reset_connection({debug => 2, uuid => $old_uuid}); ($output, $return_code) = $anvil->Network->reset_connection({uuid => $old_uuid});
} }
# Now assign the IP. # Now assign the IP.
@ -1770,7 +1766,7 @@ sub reconfigure_ip_addresses
device_uuid => $on_device_uuid, device_uuid => $on_device_uuid,
}, },
}); });
($output, $return_code) = $anvil->Network->reset_connection({debug => 2, uuid => $on_device_uuid}); ($output, $return_code) = $anvil->Network->reset_connection({uuid => $on_device_uuid});
# Rescan. # Rescan.
$anvil->Job->update_progress({ $anvil->Job->update_progress({
@ -1783,7 +1779,7 @@ sub reconfigure_ip_addresses
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
} }
@ -1847,7 +1843,7 @@ sub reconfigure_interfaces
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
} }
} }
} }
@ -1945,7 +1941,7 @@ sub reconfigure_interfaces
# Make sure that the autoconnect is enabled. # Make sure that the autoconnect is enabled.
if ($anvil->data->{nmcli}{uuid}{$link1_nm_uuid}{'connection.autoconnect'} ne "yes") if ($anvil->data->{nmcli}{uuid}{$link1_nm_uuid}{'connection.autoconnect'} ne "yes")
{ {
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $link1_nm_uuid, variable => "connection.autoconnect", value => "yes"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $link1_nm_uuid, variable => "connection.autoconnect", value => "yes"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
@ -2005,7 +2001,7 @@ sub reconfigure_interfaces
# Make sure that the autoconnect is enabled. # Make sure that the autoconnect is enabled.
if ($anvil->data->{nmcli}{uuid}{$link2_nm_uuid}{'connection.autoconnect'} ne "yes") if ($anvil->data->{nmcli}{uuid}{$link2_nm_uuid}{'connection.autoconnect'} ne "yes")
{ {
my ($output, $return_code) = $anvil->Network->modify_connection({debug => 2, uuid => $link2_nm_uuid, variable => "connection.autoconnect", value => "yes"}); my ($output, $return_code) = $anvil->Network->modify_connection({uuid => $link2_nm_uuid, variable => "connection.autoconnect", value => "yes"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
@ -2095,7 +2091,7 @@ sub rename_interface
}); });
# If there are ifcfg files for this device, move them. # If there are ifcfg files for this device, move them.
my $network_type = $anvil->System->check_network_type({debug => 2}); my $network_type = $anvil->System->check_network_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }});
if ($network_type eq "ifcfg") if ($network_type eq "ifcfg")
{ {
@ -2121,7 +2117,7 @@ sub rename_interface
job_uuid => $anvil->data->{job}{uuid}, job_uuid => $anvil->data->{job}{uuid},
variables => { file => $file }, variables => { file => $file },
}); });
$anvil->Storage->backup({debug => 2, file => $file}); $anvil->Storage->backup({file => $file});
unlink $file; unlink $file;
} }
} }
@ -2132,7 +2128,7 @@ sub rename_interface
my $old_persistent_net = ""; my $old_persistent_net = "";
if (-e $anvil->data->{path}{configs}{'persistent-net'}) if (-e $anvil->data->{path}{configs}{'persistent-net'})
{ {
$old_persistent_net = $anvil->Storage->read_file({debug => 2, file => $anvil->data->{path}{configs}{'persistent-net'}}); $old_persistent_net = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'persistent-net'}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_persistent_net => $old_persistent_net }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_persistent_net => $old_persistent_net }});
} }
foreach my $line (split/\n/, $old_persistent_net) foreach my $line (split/\n/, $old_persistent_net)
@ -2356,7 +2352,7 @@ sub rename_interface
line => __LINE__, line => __LINE__,
variables => { }, variables => { },
}); });
$anvil->Network->collect_data({debug => 2}); $anvil->Network->collect_data();
# Set the reboot flag. # Set the reboot flag.
$anvil->data->{sys}{reboot_needed} = 1; $anvil->data->{sys}{reboot_needed} = 1;

Loading…
Cancel
Save