diff --git a/Anvil/Tools.pm b/Anvil/Tools.pm
index ca0a54b1..08cf5fcb 100755
--- a/Anvil/Tools.pm
+++ b/Anvil/Tools.pm
@@ -362,26 +362,27 @@ sub nice_exit
my $self = shift;
my $parameter = shift;
my $anvil = $self;
+ my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $exit_code = defined $parameter->{exit_code} ? $parameter->{exit_code} : 0;
# Close database connections (if any).
- $anvil->Database->disconnect();
+ $anvil->Database->disconnect({debug => $debug});
# Report the runtime.
my $end_time = Time::HiRes::time;
my $run_time = $end_time - $anvil->data->{ENV_VALUES}{START_TIME};
my $caller = ($0 =~ /^.*\/(.*)$/)[0];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:ENV_VALUES::START_TIME' => $anvil->data->{ENV_VALUES}{START_TIME},
's2:end_time' => $end_time,
's3:run_time' => $run_time,
's4:caller' => $caller,
}});
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0135", variables => { 'caller' => $caller, runtime => $run_time }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0135", variables => { 'caller' => $caller, runtime => $run_time }});
my ($package, $filename, $line) = caller;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:package' => $package,
's2:filename' => $filename,
's3:line' => $line,
diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm
index 9e269c39..017f32eb 100755
--- a/Anvil/Tools/Database.pm
+++ b/Anvil/Tools/Database.pm
@@ -120,7 +120,7 @@ sub archive_database
# Is archiving disabled?
if (not $anvil->data->{sys}{database}{archive}{trigger})
{
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0189"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0189"});
return(1);
}
@@ -128,7 +128,7 @@ sub archive_database
if (($< != 0) && ($> != 0))
{
# Not root
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0188"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0188"});
return(1);
}
@@ -1373,7 +1373,7 @@ WHERE
}});
# If the job is done, see if it was recently enough to care about it.
- if (($job_progress eq "100") && ($updated_seconds_ago > $ended_within))
+ if (($job_progress eq "100") && (($updated_seconds_ago == 0) or ($updated_seconds_ago > $ended_within)))
{
# Skip it
next;
diff --git a/Anvil/Tools/Log.pm b/Anvil/Tools/Log.pm
index ef60bc02..c839157d 100755
--- a/Anvil/Tools/Log.pm
+++ b/Anvil/Tools/Log.pm
@@ -291,7 +291,8 @@ sub entry
elsif ($key)
{
# Build the string from the key/variables.
- my $message .= $anvil->Words->string({
+ my $message .= $anvil->Words->string({
+ debug => $debug,
language => $language,
key => $key,
variables => $variables,
@@ -329,7 +330,7 @@ sub entry
$anvil->data->{HANDLE}{log_file} = $file_handle;
# Make sure it can be written to by apache.
- $anvil->Storage->change_mode({target => $log_file, mode => "0666"});
+ $anvil->Storage->change_mode({debug => $debug, target => $log_file, mode => "0666"});
}
if (not $anvil->data->{HANDLE}{log_file})
diff --git a/Anvil/Tools/Storage.pm b/Anvil/Tools/Storage.pm
index 8eb5fb0b..7b9e2364 100755
--- a/Anvil/Tools/Storage.pm
+++ b/Anvil/Tools/Storage.pm
@@ -1008,11 +1008,11 @@ fi;";
if ($mode)
{
- $anvil->Storage->change_mode({target => $working_directory, mode => $mode});
+ $anvil->Storage->change_mode({debug => $debug, target => $working_directory, mode => $mode});
}
if (($user) or ($group))
{
- $anvil->Storage->change_owner({target => $working_directory, user => $user, group => $group});
+ $anvil->Storage->change_owner({debug => $debug, target => $working_directory, user => $user, group => $group});
}
if (not -e $working_directory)
@@ -2260,11 +2260,8 @@ fi";
# the mode before writing it.
if ($secure)
{
- my $shell_call = $anvil->data->{path}{exe}{touch}." ".$file;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
-
- $anvil->System->call({shell_call => $shell_call});
- $anvil->Storage->change_mode({target => $file, mode => $mode});
+ $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{touch}." ".$file});
+ $anvil->Storage->change_mode({debug => $debug, target => $file, mode => $mode});
}
# Now write the file.
@@ -2276,11 +2273,11 @@ fi";
if ($mode)
{
- $anvil->Storage->change_mode({target => $file, mode => $mode});
+ $anvil->Storage->change_mode({debug => $debug, target => $file, mode => $mode});
}
if (($user) or ($group))
{
- $anvil->Storage->change_owner({target => $file, user => $user, group => $group});
+ $anvil->Storage->change_owner({debug => $debug, target => $file, user => $user, group => $group});
}
}
}
diff --git a/cgi-bin/striker b/cgi-bin/striker
index d2d0c2aa..3d4a7c1f 100755
--- a/cgi-bin/striker
+++ b/cgi-bin/striker
@@ -52,7 +52,7 @@ if (not -e $anvil->data->{path}{data}{host_uuid})
}
$anvil->Database->connect();
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, exit.
@@ -63,7 +63,7 @@ if (not $anvil->data->{sys}{database}{connections})
# If any jobs are pending/running, show the "unavailable" option.
my $available = check_availability($anvil);
my $configured = $available ? check_if_configured($anvil) : 0;
-$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
available => $available,
configured => $configured,
}});
@@ -140,7 +140,7 @@ sub print_and_exit
}});
# Display the page.
- my $body = $anvil->Template->get({debug => 3, file => "main.html", name => "master", variables => {
+ my $body = $anvil->Template->get({file => "main.html", name => "master", variables => {
header => $header,
skin_url => $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin,
center_top_bar => $anvil->data->{form}{error_massage} ? $anvil->data->{form}{error_massage} : " ",
@@ -173,7 +173,7 @@ sub process_task
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::login::value" => $anvil->data->{cgi}{login}{value} }});
# Woot!
- my $failed = $anvil->Account->login({debug => 3});
+ my $failed = $anvil->Account->login();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { failed => $failed }});
if (not $failed)
{
@@ -195,7 +195,7 @@ sub process_task
# cookies were deleted (via C<< Account->logout() >>. The user needs to log back in.
# 3 - There user's hash is invalid, it is probably expired. The user has been logged out and
# needs to log back in.
- my $cookie_problem = $anvil->Account->read_cookies({debug => 2});
+ my $cookie_problem = $anvil->Account->read_cookies();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { cookie_problem => $cookie_problem }});
if (not $cookie_problem)
{
@@ -292,7 +292,6 @@ sub process_power
{
# Record the job!
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
job_command => $task eq "poweroff" ? "anvil-manage-power --poweroff -y" : "anvil-manage-power --reboot -y",
@@ -339,7 +338,6 @@ sub process_update
{
# Record the job!
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
job_command => "anvil-update-system",
@@ -361,7 +359,7 @@ sub process_update
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }});
# Set maintenance mode.
- $anvil->System->maintenance_mode({debug => 2, set => 1});
+ $anvil->System->maintenance_mode({set => 1});
}
else
{
@@ -638,7 +636,6 @@ sub add_sync_peer
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($error, $output) = $anvil->Remote->call({
- debug => 2,
password => $anvil->data->{cgi}{new_peer_password}{value},
target => $ssh_tcp != 22 ? $host.":".$ssh_tcp : $host,
shell_call => $shell_call,
@@ -662,7 +659,6 @@ sub add_sync_peer
else
{
my ($error, $output) = $anvil->Remote->call({
- debug => 2,
password => $anvil->data->{cgi}{new_peer_password}{value},
target => $ssh_tcp != 22 ? $host.":".$ssh_tcp : $host,
shell_call => $anvil->data->{path}{exe}{hostnamectl}." --static",
@@ -781,7 +777,6 @@ sub configure_striker
{
# User has confirmed, update the system!
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
job_command => "anvil-configure-striker",
@@ -793,7 +788,7 @@ sub configure_striker
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
# Set maintenance mode.
- $anvil->System->maintenance_mode({debug => 2, set => 1});
+ $anvil->System->maintenance_mode({set => 1});
# We don't need to store anything as hidden variables, we'll read it back from the database later.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "network_job_recorded", variables => {
@@ -839,7 +834,7 @@ sub check_availability
{
my ($anvil) = @_;
- my $debug = 2;
+ my $debug = 3;
my $available = 1;
# Check maintenance mode.
@@ -2335,7 +2330,7 @@ sub get_network_details_form
sub generate_ip
{
my ($anvil, $network, $network_sequence, $device_sequence) = @_;
- my $debug = 2;
+ my $debug = 3;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
network => $network,
network_sequence => $network_sequence,
diff --git a/share/words.xml b/share/words.xml
index 1bc45d19..79e84526 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -346,6 +346,7 @@ The database connection error was:
update_progress() called without 'job_uuid' being set, and 'jobs::job_uuid' was also not set. Unable to find the job to update.]]>
update_progress() called with the 'job_uuid': [#!variable!job_uuid!#], which was not found. Unable to find the job to update.]]>
update_progress() called with 'progress' set to an invalid value: [#!variable!progress!#]. This must be a whole number between '0' and '100' (fractions not allowed).]]>
+
Test
diff --git a/tools/anvil-configure-striker b/tools/anvil-configure-striker
index 9cf4b03f..7cd7abc4 100755
--- a/tools/anvil-configure-striker
+++ b/tools/anvil-configure-striker
@@ -26,7 +26,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1;
-my $anvil = Anvil::Tools->new({log_level => 1, log_secure => 1});
+my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
# Read switches
$anvil->data->{switches}{'no-reboot'} = 0;
@@ -34,6 +34,7 @@ $anvil->Get->switches;
# Paths
$anvil->Storage->read_config({file => $anvil->data->{path}{configs}{'anvil.conf'}});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Make sure we're running as 'root'
# $< == real UID, $> == effective UID
@@ -55,17 +56,19 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->nice_exit({exit_code => 2});
}
+# Set maintenance mode
+$anvil->System->maintenance_mode({set => 1});
+
pickup_job_details($anvil);
reconfigure_network($anvil);
update_passwords($anvil);
-$anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 100,
- job_status => $anvil->data->{job}{status},
+$anvil->Job->update_progress({
+ debug => 3,
+ progress => 100,
+ job_uuid => $anvil->data->{job}{uuid},
});
# Record that we've configured this machine.
@@ -79,17 +82,23 @@ $anvil->Database->insert_or_update_variables({
variable_source_table => "hosts",
});
# Clear maintenance mode.
-$anvil->System->maintenance_mode({debug => 2, set => 0});
+$anvil->System->maintenance_mode({set => 0});
+
+# Clear maintenance mode
+$anvil->System->maintenance_mode({set => 0});
### TODO: This is only until we can get the damn networking stable on reconfigure.
+# Set reboot needed so that things clean up properly on reboot.
+$anvil->System->reboot_needed({set => 1});
if (not $anvil->data->{switches}{'no-reboot'})
{
# Reboot.
- $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'shutdown'}." --reboot now"});
+ $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'anvil-manager-power'}." --reboot -y"});
}
$anvil->nice_exit({code => 0});
+
#############################################################################################################
# Functions #
#############################################################################################################
@@ -102,12 +111,11 @@ sub update_passwords
# Set the passwords
my $password = $anvil->data->{variables}{form}{config_step2}{striker_password}{value};
my $temp_file = "/tmp/anvil-".$anvil->Get->uuid;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { password => $password }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 1, list => { password => $password }});
# Write the password into a temporary file.
my $error = $anvil->Storage->write_file({
body => $password,
- debug => 2,
file => $temp_file,
group => "root",
mode => "0600",
@@ -126,15 +134,15 @@ sub update_passwords
else
{
my $return_code = "";
- my $output = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{'anvil-change-password'}." -y --password-file ".$temp_file."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$!" });
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { output => $output }});
+ my $output = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{'anvil-change-password'}." -y --password-file ".$temp_file."; ".$anvil->data->{path}{exe}{'echo'}." return_code:\$!" });
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => { output => $output }});
foreach my $line (split/\n/, $output)
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { line => $line }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => { line => $line }});
if ($line =~ /return_code:(\d+)$/)
{
$return_code = $1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { return_code => $return_code }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => { return_code => $return_code }});
}
}
@@ -148,11 +156,9 @@ sub update_passwords
}
}
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 95,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 95,
+ job_uuid => $anvil->data->{job}{uuid},
});
return(0);
@@ -172,7 +178,7 @@ sub reconfigure_network
my $ifn_count = $anvil->data->{variables}{form}{config_step1}{ifn_count}{value};
my $new_hostname = defined $anvil->data->{variables}{form}{config_step2}{hostname}{value} ? $anvil->data->{variables}{form}{config_step2}{hostname}{value} : $prefix."-striker".sprintf("%02d", $sequence).".".$domain;
my $pretty_hostname = $organization." - Striker ".sprintf("%02d", $sequence);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => {
prefix => $prefix,
sequence => $sequence,
domain => $domain,
@@ -184,30 +190,25 @@ sub reconfigure_network
}});
# Set the hostname
- my $hostname = $anvil->System->hostname({set => $new_hostname, pretty => $pretty_hostname, debug => 2});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { hostname => $hostname }});
+ my $hostname = $anvil->System->hostname({set => $new_hostname, pretty => $pretty_hostname, debug => 3});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { hostname => $hostname }});
if ($hostname eq $new_hostname)
{
# Success
- $anvil->data->{job}{status} .= "message_0016,!!hostname!$new_hostname!!\n";
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 10,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 10,
+ message => "message_0016,!!hostname!$new_hostname!!",
+ job_uuid => $anvil->data->{job}{uuid},
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0016", variables => { hostname => $new_hostname }});
}
else
{
# Failed
- $anvil->data->{job}{status} .= "message_0017,!!hostname!$new_hostname!!,!!bad_hostname!$hostname!!\n";
- $anvil->data->{job}{status} .= "failed\n";
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 100,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 0,
+ message => "message_0017,!!hostname!$new_hostname!!,!!bad_hostname!$hostname!!",
+ job_uuid => $anvil->data->{job}{uuid},
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "message_0017", variables => {
hostname => $new_hostname,
@@ -221,28 +222,28 @@ sub reconfigure_network
# Now configure the network.
my $dns = defined $anvil->data->{variables}{form}{config_step2}{dns}{value} ? [split/,/, $anvil->data->{variables}{form}{config_step2}{dns}{value}] : [];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dns => $dns }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dns => $dns }});
for (my $i = 0; $i < @{$dns}; $i++)
{
$dns->[$i] = $anvil->Words->clean_spaces({ string => $dns->[$i] });
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "dns->[$i]" => $dns->[$i] }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "dns->[$i]" => $dns->[$i] }});
}
my $gateway = defined $anvil->data->{variables}{form}{config_step2}{gateway}{value} ? $anvil->data->{variables}{form}{config_step2}{gateway}{value} : "";
my $gateway_interface = defined $anvil->data->{variables}{form}{config_step2}{gateway_interface}{value} ? $anvil->data->{variables}{form}{config_step2}{gateway_interface}{value} : "";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
gateway => $gateway,
gateway_interface => $gateway_interface,
}});
foreach my $network_type ("bcn", "sn", "ifn")
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_type => $network_type }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_type => $network_type }});
my $count = 0;
if ($network_type eq "bcn") { $count = $bcn_count; }
elsif ($network_type eq "sn") { $count = $sn_count; }
elsif ($network_type eq "ifn") { $count = $ifn_count; }
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { count => $count }});
next if not $count;
foreach my $network_count (1..$count)
@@ -257,7 +258,7 @@ sub reconfigure_network
my $link2_mac = defined $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} : "";
my $old_link1_iface = $anvil->data->{sys}{mac}{$link1_mac}{iface} ? $anvil->data->{sys}{mac}{$link1_mac}{iface} : "";
my $old_link2_iface = defined $anvil->data->{sys}{mac}{$link2_mac}{iface} ? $anvil->data->{sys}{mac}{$link2_mac}{iface} : "";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_key => $ip_key,
is_gateway => $is_gateway,
link1_key => $link1_key,
@@ -278,7 +279,7 @@ sub reconfigure_network
}
else
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "variables::form::config_step2::${ip_key}::value" => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "variables::form::config_step2::${ip_key}::value" => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value} }});
}
if (($anvil->data->{variables}{form}{config_step2}{$ip_key}{value}) and (not $anvil->Validate->is_ipv4({ip => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value}})))
{
@@ -292,7 +293,7 @@ sub reconfigure_network
my $ip = $anvil->data->{variables}{form}{config_step2}{$ip_key}{value};
my $subnet = $anvil->data->{variables}{form}{config_step2}{$subnet_key}{value};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip => $ip,
subnet => $subnet,
}});
@@ -341,7 +342,7 @@ sub reconfigure_network
{
$old_link2_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{sys}{mac}{$link2_mac}{iface};
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
say_defroute => $say_defroute,
cidr => $cidr,
bond_file => $bond_file,
@@ -358,7 +359,7 @@ sub reconfigure_network
my $bond_uuid = get_uuid_from_interface_file($anvil, $bond_file);
my $link1_uuid = get_uuid_from_interface_file($anvil, $old_link1_file);
my $link2_uuid = get_uuid_from_interface_file($anvil, $old_link2_file);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
bond_uuid => $bond_uuid,
link1_uuid => $link1_uuid,
link2_uuid => $link2_uuid,
@@ -525,7 +526,7 @@ sub reconfigure_network
{
# Single interface, set it up
my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { link1_mac => $link1_mac }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { link1_mac => $link1_mac }});
my $say_network = "";
my $say_interface = "";
@@ -557,7 +558,7 @@ sub reconfigure_network
{
$old_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{sys}{mac}{$link1_mac}{iface};
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
say_defroute => $say_defroute,
cidr => $cidr,
new_link1_file => $new_link1_file,
@@ -567,7 +568,7 @@ sub reconfigure_network
# Gather (or create) UUIDs
my $link1_uuid = get_uuid_from_interface_file($anvil, $old_link1_file);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { link1_uuid => $link1_uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { link1_uuid => $link1_uuid }});
my $link1_config = "# $say_network - Link 1\n";
$link1_config .= "HWADDR=\"".uc($link1_mac)."\"\n";
@@ -638,48 +639,46 @@ sub reconfigure_network
}
}
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 50,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 50,
+ job_uuid => $anvil->data->{job}{uuid},
});
# If any virtio bridges exist, remove it/them.
my $start = 0;
my $bridges = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." net-list"});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridges => $bridges }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bridges => $bridges }});
foreach my $line (split/\n/, $bridges)
{
- $line = $anvil->Words->clean_spaces({ string => $line });
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
+ $line = $anvil->Words->clean_spaces({string => $line});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /^----------/)
{
$start = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { start => $start }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { start => $start }});
next;
}
next if not $start;
my $bridge = ($line =~ /(.*?)\s/)[0];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridge => $bridge }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bridge => $bridge }});
$anvil->data->{virsh}{bridge}{$bridge} = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "virsh::bridge::$bridge" => $anvil->data->{virsh}{bridge}{$bridge} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "virsh::bridge::$bridge" => $anvil->data->{virsh}{bridge}{$bridge} }});
}
foreach my $bridge (sort {$a cmp $b} keys %{$anvil->data->{virsh}{bridge}})
{
# Destroy (stop) it.
my $destroy = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." net-destroy ".$bridge});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { destroy => $destroy }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { destroy => $destroy }});
# Disable it from auto-start.
my $disable = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." net-autostart ".$bridge." --disable"});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { disable => $disable }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { disable => $disable }});
# Undefine (delete)
my $undefine = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." net-undefine ".$bridge});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { undefine => $undefine }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { undefine => $undefine }});
}
### TODO: This isn't working... The route table won't set the IFN as the default route properly and
@@ -689,11 +688,9 @@ sub reconfigure_network
#print "reloading nmcli\n";
#$anvil->System->call({shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"});
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 75,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 75,
+ job_uuid => $anvil->data->{job}{uuid},
});
return(0);
@@ -704,8 +701,8 @@ sub reconfigure_network
sub get_uuid_from_interface_file
{
my ($anvil, $file) = @_;
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0131", variables => { function => "get_uuid_from_interface_file" }});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file => $file }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0131", variables => { function => "get_uuid_from_interface_file" }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
my $uuid = "";
if (-e $file)
@@ -713,16 +710,16 @@ sub get_uuid_from_interface_file
my $body = $anvil->Storage->read_file({file => $file});
foreach my $line (split/\n/, $body)
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
$line =~ s/#.*//;
if ($line =~ /UUID=\"(.*?)\"/)
{
my $test_uuid = $1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { test_uuid => $test_uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { test_uuid => $test_uuid }});
if ($anvil->Validate->is_uuid({uuid => $test_uuid}))
{
$uuid = $test_uuid;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uuid => $uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uuid => $uuid }});
}
last;
}
@@ -731,10 +728,10 @@ sub get_uuid_from_interface_file
if (not $uuid)
{
$uuid = $anvil->Get->uuid();
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uuid => $uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uuid => $uuid }});
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uuid => $uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uuid => $uuid }});
return($uuid);
}
@@ -764,11 +761,11 @@ AND
AND
job_host_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->Get->host_uuid)."
LIMIT 1;";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
@@ -779,7 +776,7 @@ LIMIT 1;";
my $job_picked_up_at = $results->[0]->[4];
my $job_updated = $results->[0]->[5];
my $job_progress = $results->[0]->[6];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_uuid => $job_uuid,
job_command => $job_command,
job_data => $job_data,
@@ -832,11 +829,11 @@ AND
AND
variable_source_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->Get->host_uuid)."
;";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
@@ -845,7 +842,7 @@ AND
my $this_variable = $row->[0];
my $this_value = $row->[1];
my $secure = $this_variable =~ /passw/ ? 1 : 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
this_variable => $this_variable,
this_value => (($anvil->Log->secure) or (not $secure)) ? $this_value : $anvil->Words->string({key => "log_0186"}),
}});
@@ -854,15 +851,13 @@ AND
}
# This will be used when updating the job
- $anvil->data->{job}{uuid} = $job_uuid;
- $anvil->data->{job}{status} = "message_0015\n";
+ $anvil->data->{job}{uuid} = $job_uuid;
# Record that we've picked up this job.
- $anvil->Database->insert_or_update_jobs({
- job_uuid => $anvil->data->{job}{uuid},
- update_progress_only => 1,
- job_progress => 1,
- job_status => $anvil->data->{job}{status},
+ $anvil->Job->update_progress({
+ progress => 1,
+ message => "message_0015",
+ job_uuid => $anvil->data->{job}{uuid},
});
return(0);
diff --git a/tools/anvil-daemon b/tools/anvil-daemon
index 7d1e9350..1ccade9c 100755
--- a/tools/anvil-daemon
+++ b/tools/anvil-daemon
@@ -22,6 +22,7 @@ use strict;
use warnings;
use Anvil::Tools;
use Proc::Simple;
+use Time::HiRes qw ( time sleep );
use JSON;
use HTML::Strip;
use HTML::FromText;
@@ -37,6 +38,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$| = 1;
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks
# is to setup the database server.
@@ -53,7 +55,7 @@ if (not $anvil->data->{sys}{database}{connections})
# Try connecting again
$anvil->Database->connect();
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# Still nothing, sleep and exit.
@@ -86,7 +88,7 @@ $anvil->Storage->record_md5sums;
# Disconnect. We'll reconnect inside the loop
$anvil->Database->disconnect();
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0203"});
# This will prevent restarting while jobs are running.
$anvil->data->{sys}{jobs_running} = 0;
@@ -97,7 +99,7 @@ while(1)
# Connect to the database(s)
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
$anvil->Database->connect();
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if ($anvil->data->{sys}{database}{connections})
{
@@ -131,7 +133,7 @@ while(1)
# Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect();
- sleep 2;
+ sleep(0.5);
}
$anvil->nice_exit({code => 0});
@@ -168,17 +170,16 @@ sub boot_time_tasks
# If the uptime is less than ten minutes, clear the reboot flag.
my $uptime = $anvil->Storage->read_file({
- debug => 2,
force_read => 1,
cache => 0,
file => $anvil->data->{path}{proc}{uptime},
});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uptime => $uptime }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uptime => $uptime }});
# Clean it up. We'll have gotten two numbers, the uptime in seconds (to two decimal places) and the
# total idle time. We only care about the int number.
$uptime =~ s/^(\d+)\..*$/$1/;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uptime => $uptime }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uptime => $uptime }});
# Now find out if a reboot is needed and when it was last changed.
my $reboot_needed = 0;
@@ -198,7 +199,7 @@ AND
;";
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
@@ -207,7 +208,7 @@ AND
$reboot_needed = $results->[0]->[0];
$changed_seconds_ago = $results->[0]->[1];
$changed_seconds_ago =~ s/^(\d+)\..*$/$1/;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
reboot_needed => $reboot_needed,
changed_seconds_ago => $changed_seconds_ago,
}});
@@ -216,7 +217,7 @@ AND
# If a reboot is needed, see if the uptime is less than the time since the reboot needed flag was
# set. If the uptime is less, then the system rebooted since it was requested so clear it. h/t to
# Lisa Seelye (@thedoh) for this idea!
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
reboot_needed => $reboot_needed,
changed_seconds_ago => $changed_seconds_ago,
uptime => $uptime,
@@ -225,11 +226,11 @@ AND
{
# Clear the reboot request.
$reboot_needed = $anvil->System->reboot_needed({set => 0});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { reboot_needed => $reboot_needed }});
# Check to see if there was a reboot job in progress. If so, finish it off.
- my $job_uuid = $anvil->Job->get_job_uuid({debug => 2, program => "anvil-manage-power"});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
+ my $job_uuid = $anvil->Job->get_job_uuid({program => "anvil-manage-power"});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { job_uuid => $job_uuid }});
if ($job_uuid)
{
@@ -238,7 +239,6 @@ AND
if ($anvil->data->{jobs}{job_uuid})
{
$anvil->Job->update_progress({
- debug => 2,
progress => 100,
message => "message_0064,!!date_and_time!".$date_time."!!",
job_uuid => $job_uuid
@@ -279,7 +279,7 @@ sub keep_running
{
# If it's not a handle, delete it.
my $running = $anvil->data->{jobs}{handles}{$job_uuid}->poll();
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid},
running => $running,
}});
@@ -288,7 +288,10 @@ sub keep_running
if (not $running)
{
my $exit_status = $anvil->data->{jobs}{handles}{$job_uuid}->exit_status();
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { exit_status => $exit_status }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => {
+ job_uuid => $job_uuid,
+ exit_status => $exit_status,
+ }});
# Free up memory
$anvil->data->{jobs}{handles}{$job_uuid}->cleanup();
@@ -324,7 +327,7 @@ sub run_jobs
# Get a list of pending or incomplete jobs.
my $return = $anvil->Database->get_jobs({ended_within => 300});
my $count = @{$return};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
'return' => $return,
count => $count,
}});
@@ -343,7 +346,7 @@ sub run_jobs
my $job_status = $hash_ref->{job_status};
my $started_seconds_ago = $job_picked_up_at ? (time - $job_picked_up_at) : 0;
my $updated_seconds_ago = $job_updated ? (time - $job_updated) : 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_uuid => $job_uuid,
job_command => $job_command,
job_data => $job_data,
@@ -362,7 +365,7 @@ sub run_jobs
if ($job_progress ne "100")
{
$anvil->data->{sys}{jobs_running} = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::jobs_running" => $anvil->data->{sys}{jobs_running} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "sys::jobs_running" => $anvil->data->{sys}{jobs_running} }});
}
# See if the job was picked up by a now-dead instance.
@@ -389,7 +392,7 @@ sub run_jobs
# Clear some variables.
$job_progress = 0;
$job_status = "message_0056";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_progress => $job_progress,
job_status => $job_status,
}});
@@ -397,15 +400,15 @@ sub run_jobs
# Clear the PID
$job_picked_up_by = 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_picked_up_by => $job_picked_up_by }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { job_picked_up_by => $job_picked_up_by }});
}
}
# Convert the double-banged strings into a proper message.
- my $say_title = $job_title ? $anvil->Words->parse_banged_string({debug => 2, key_string => $job_title}) : "";
- my $say_description = $job_description ? $anvil->Words->parse_banged_string({debug => 2, key_string => $job_description}) : "";
- my $say_status = $job_status ? $anvil->Words->parse_banged_string({debug => 2, key_string => $job_status}) : "";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
+ my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
+ my $say_status = $job_status ? $anvil->Words->parse_banged_string({key_string => $job_status}) : "";
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_title => $job_title,
say_description => $say_description,
say_status => $say_status,
@@ -416,7 +419,7 @@ sub run_jobs
{
my $html_strip = HTML::Strip->new();
$say_status = $html_strip->parse($say_status);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_status => $say_status }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
# Now make the resulting text string HTML friendly
my $text_to_html = HTML::FromText->new({
@@ -425,7 +428,7 @@ sub run_jobs
lines => 1,
});
$say_status = $text_to_html->parse($say_status);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_status => $say_status }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
}
# Add this to the jobs.json file
@@ -443,7 +446,7 @@ sub run_jobs
started_seconds_ago => $started_seconds_ago,
updated_seconds_ago => $updated_seconds_ago,
});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { json_string => $json_string }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { json_string => $json_string }});
$jobs_file .= $json_string.",\n";
# If the job is done, move on.
@@ -453,27 +456,28 @@ sub run_jobs
if ((not $job_picked_up_by) && (not $anvil->data->{switches}{'no-start'}))
{
# Start the job, appending '--job-uuid' to the command.
+ my $command = $job_command." --job-uuid ".$job_uuid;
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0210", variables => { command => $command }});
$anvil->data->{jobs}{handles}{$job_uuid} = $anvil->System->call({
- debug => 2,
background => 1,
stdout_file => "/tmp/anvil.job.".$job_uuid.".stdout",
stderr_file => "/tmp/anvil.job.".$job_uuid.".stderr",
- shell_call => $job_command." --job-uuid ".$job_uuid,
+ shell_call => $command,
source => $THIS_FILE,
line => __LINE__,
});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid} }});
# Log the PID (the job should update the database).
my $pid = $anvil->data->{jobs}{handles}{$job_uuid}->pid();
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { pid => $pid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { pid => $pid }});
}
}
# Close the jobs file.
$jobs_file =~ s/,\n$/\n/ms;
$jobs_file .= "]}\n";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { jobs_file => $jobs_file }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { jobs_file => $jobs_file }});
# Write the JSON file
my $output_json = $anvil->data->{path}{directories}{html}."/status/jobs.json";
@@ -496,10 +500,7 @@ sub update_state_file
{
my ($anvil) = @_;
- my $shell_call = $anvil->data->{path}{exe}{'anvil-update-states'};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { shell_call => $shell_call }});
-
- my $states_output = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});
+ my $states_output = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{'anvil-update-states'}, source => $THIS_FILE, line => __LINE__});
if ($states_output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { states_output => $states_output }});
diff --git a/tools/anvil-manage-power b/tools/anvil-manage-power
index 4c279cc4..eb27cf6c 100755
--- a/tools/anvil-manage-power
+++ b/tools/anvil-manage-power
@@ -35,6 +35,7 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
$anvil->data->{switches}{'poweroff'} = "";
diff --git a/tools/anvil-prep-database b/tools/anvil-prep-database
index 2f19b29a..48a4bc3c 100755
--- a/tools/anvil-prep-database
+++ b/tools/anvil-prep-database
@@ -26,32 +26,33 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1;
-my $anvil = Anvil::Tools->new({log_level => 3, log_secure => 0});
+my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 0});
# Read switches
$anvil->Get->switches;
# Read in our config.
$anvil->Storage->read_config({file => $anvil->data->{path}{configs}{'anvil.conf'}});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
my $local_uuid = $anvil->Database->get_local_uuid();
-$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { local_uuid => $local_uuid }});
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { local_uuid => $local_uuid }});
# If we didn't get the $local_uuid, then there is no entry for this system in anvil.conf yet, so we'll add it.
if (not $local_uuid)
{
$local_uuid = add_to_local_config($anvil);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { local_uuid => $local_uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { local_uuid => $local_uuid }});
}
# Now configure!
if ($local_uuid)
{
# Start checks
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::service::postgresql" => $anvil->data->{sys}{service}{postgresql} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "sys::service::postgresql" => $anvil->data->{sys}{service}{postgresql} }});
- my $running = $anvil->System->check_daemon({debug => 2, daemon => $anvil->data->{sys}{service}{postgresql}});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { running => $running }});
+ my $running = $anvil->System->check_daemon({daemon => $anvil->data->{sys}{service}{postgresql}});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { running => $running }});
if ($running eq "2")
{
# Not installed.
@@ -61,11 +62,11 @@ if ($local_uuid)
elsif (not $running)
{
# Do we need to initialize the databae?
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "path::configs::pg_hba.conf" => $anvil->data->{path}{configs}{'pg_hba.conf'} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "path::configs::pg_hba.conf" => $anvil->data->{path}{configs}{'pg_hba.conf'} }});
if (-e $anvil->data->{path}{configs}{'pg_hba.conf'})
{
# It already exists.
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "path::configs::pg_hba.conf" => $anvil->data->{path}{configs}{'pg_hba.conf'} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "path::configs::pg_hba.conf" => $anvil->data->{path}{configs}{'pg_hba.conf'} }});
}
else
{
@@ -101,7 +102,7 @@ if ($local_uuid)
# Setup postgresql.conf
my $postgresql_backup = $anvil->data->{path}{directories}{backups}."/pgsql/postgresql.conf";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { postgresql_backup => $postgresql_backup }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { postgresql_backup => $postgresql_backup }});
$anvil->Storage->copy_file({
source_file => $anvil->data->{path}{configs}{'postgresql.conf'},
target_file => $postgresql_backup,
@@ -130,6 +131,7 @@ if ($local_uuid)
if ($update_file)
{
$anvil->Storage->write_file({
+ debug => 2,
file => $anvil->data->{path}{configs}{'postgresql.conf'},
body => $new_postgresql_conf,
user => "postgres",
@@ -153,12 +155,12 @@ if ($local_uuid)
my $new_pg_hba_conf = "";
foreach my $line (split/\n/, $pg_hba_conf)
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
if ($line =~ /^host\s+all\s+all\s+\all\s+md5$/)
{
# No need to update.
$update_file = 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update_file => $update_file }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update_file => $update_file }});
last;
}
elsif ($line =~ /^# TYPE\s+DATABASE/)
@@ -176,6 +178,7 @@ if ($local_uuid)
if ($update_file)
{
$anvil->Storage->write_file({
+ debug => 2,
file => $anvil->data->{path}{configs}{'pg_hba.conf'},
body => $new_pg_hba_conf,
user => "postgres",
@@ -188,7 +191,7 @@ if ($local_uuid)
}
# Start the daemon. '0' = started, anything else is a problem.
- my $return_code = $anvil->System->start_daemon({debug => 2, daemon => $anvil->data->{sys}{service}{postgresql}});
+ my $return_code = $anvil->System->start_daemon({daemon => $anvil->data->{sys}{service}{postgresql}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }});
if ($return_code eq "0")
{
@@ -229,14 +232,14 @@ if ($local_uuid)
if (-e $anvil->data->{path}{secure}{postgres_pgpass})
{
$created_pgpass = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { created_pgpass => $created_pgpass }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { created_pgpass => $created_pgpass }});
}
}
# Does the database user exist?
my $create_user = 1;
my $database_user = $anvil->data->{database}{$local_uuid}{user} ? $anvil->data->{database}{$local_uuid}{user} : $anvil->data->{sys}{database}{user};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { database_user => $database_user }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { database_user => $database_user }});
if (not $database_user)
{
# No database user defined
@@ -244,24 +247,24 @@ if ($local_uuid)
$anvil->nice_exit({code => 3});
}
my $user_list = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c 'SELECT usename, usesysid FROM pg_catalog.pg_user;'\"", source => $THIS_FILE, line => __LINE__});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { user_list => $user_list }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { user_list => $user_list }});
foreach my $line (split/\n/, $user_list)
{
if ($line =~ /^ $database_user\s+\|\s+(\d+)/)
{
# User exists already
my $id = $1;
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0060", variables => { user => $database_user, id => $id }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0060", variables => { user => $database_user, id => $id }});
$create_user = 0;
last;
}
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { create_user => $create_user }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { create_user => $create_user }});
if ($create_user)
{
# Create the user
- my $create_output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{createuser}." --no-superuser --createdb --no-createrole $database_user\"", source => $THIS_FILE, line => __LINE__});
- my $user_list = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c 'SELECT usename, usesysid FROM pg_catalog.pg_user;'\"", source => $THIS_FILE, line => __LINE__});
+ my $create_output = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{createuser}." --no-superuser --createdb --no-createrole $database_user\"", source => $THIS_FILE, line => __LINE__});
+ my $user_list = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c 'SELECT usename, usesysid FROM pg_catalog.pg_user;'\"", source => $THIS_FILE, line => __LINE__});
my $user_exists = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { create_output => $create_output, user_list => $user_list }});
foreach my $line (split/\n/, $user_list)
@@ -270,7 +273,7 @@ if ($local_uuid)
{
# Success!
my $id = $1;
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0095", variables => { user => $database_user, id => $id }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0095", variables => { user => $database_user, id => $id }});
$user_exists = 1;
last;
}
@@ -282,19 +285,19 @@ if ($local_uuid)
}
# Update/set the passwords.
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { "database::${local_uuid}::password" => $anvil->data->{database}{$local_uuid}{password} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 1, list => { "database::${local_uuid}::password" => $anvil->data->{database}{$local_uuid}{password} }});
if ($anvil->data->{database}{$local_uuid}{password})
{
foreach my $user ("postgres", $database_user)
{
my $update_output = $anvil->System->call({secure => 1, shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c \\\"ALTER ROLE $user WITH PASSWORD '".$anvil->data->{database}{$local_uuid}{password}."';\\\"\"", source => $THIS_FILE, line => __LINE__});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { update_output => $update_output }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 1, list => { update_output => $update_output }});
foreach my $line (split/\n/, $user_list)
{
if ($line =~ /ALTER ROLE/)
{
# Password set
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0100", variables => { user => $user }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0100", variables => { user => $user }});
}
}
}
@@ -304,21 +307,21 @@ if ($local_uuid)
# Create the database, if needed.
my $create_database = 1;
my $database_name = $anvil->data->{database}{$local_uuid}{name} ? $anvil->data->{database}{$local_uuid}{name} : $anvil->data->{sys}{database}{name};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { database_name => $database_name }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { database_name => $database_name }});
my $database_list = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c 'SELECT datname FROM pg_catalog.pg_database;'\"", source => $THIS_FILE, line => __LINE__});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { database_list => $database_list }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { database_list => $database_list }});
foreach my $line (split/\n/, $database_list)
{
if ($line =~ /^ $database_name$/)
{
# Database already exists.
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0105", variables => { database => $database_name }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0105", variables => { database => $database_name }});
$create_database = 0;
last;
}
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { create_database => $create_database }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { create_database => $create_database }});
if ($create_database)
{
my $create_output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{createdb}." --owner ".$database_user." ".$database_name."\"", source => $THIS_FILE, line => __LINE__});
@@ -326,13 +329,13 @@ if ($local_uuid)
my $database_exists = 0;
my $database_list = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{su}." - postgres -c \"".$anvil->data->{path}{exe}{psql}." template1 -c 'SELECT datname FROM pg_catalog.pg_database;'\"", source => $THIS_FILE, line => __LINE__});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { database_list => $database_list }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { database_list => $database_list }});
foreach my $line (split/\n/, $database_list)
{
if ($line =~ /^ $database_name$/)
{
# Database created
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0110", variables => { database => $database_name }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0110", variables => { database => $database_name }});
$database_exists = 1;
last;
}
@@ -388,6 +391,7 @@ RateLimitInterval=0
RateLimitBurst=0
";
$anvil->Storage->write_file({
+ debug => 2,
file => $anvil->data->{path}{configs}{'journald_anvil'},
body => $body,
user => "root",
@@ -397,10 +401,7 @@ RateLimitBurst=0
});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0012", variables => { file => $anvil->data->{path}{configs}{'journald_anvil'} }});
- my $shell_call = $anvil->data->{path}{exe}{systemctl}." restart systemd-journald.service";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
-
- my $output = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});
+ my $output = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{systemctl}." restart systemd-journald.service", source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
}
}
@@ -426,7 +427,6 @@ sub add_to_local_config
my $password_file = "/tmp/anvil-manage-striker-peers.".$anvil->Get->uuid;
$anvil->Storage->write_file({
secure => 1,
- debug => 2,
file => $password_file,
body => "Initial1",
mode => "0600",
@@ -436,7 +436,6 @@ sub add_to_local_config
# Make the shell call, and parse the output looking for our own entry
my $host_uuid = $anvil->Get->host_uuid();
my $output = $anvil->System->call({
- debug => 2,
shell_call => $anvil->data->{path}{exe}{'anvil-manage-striker-peers'}." --add --host-uuid ".$anvil->Get->host_uuid." --host localhost --port 5432 --password-file ".$password_file." --ping 0",
source => $THIS_FILE,
line => __LINE__,
diff --git a/tools/anvil-update-states b/tools/anvil-update-states
index 1507e28c..774ceeaa 100755
--- a/tools/anvil-update-states
+++ b/tools/anvil-update-states
@@ -18,12 +18,14 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/;
}
-my $anvil = Anvil::Tools->new({log_level => 1, log_secure => 1});
+my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
+
$anvil->Database->connect;
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, exit.
@@ -35,6 +37,7 @@ update_network($anvil);
$anvil->nice_exit({exit_code => 0});
+
#############################################################################################################
# Functions #
#############################################################################################################
@@ -62,7 +65,7 @@ sub update_network
};
local(*DIRECTORY);
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0018", variables => { directory => $directory }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0018", variables => { directory => $directory }});
opendir(DIRECTORY, $directory);
while(my $file = readdir(DIRECTORY))
{
@@ -71,7 +74,7 @@ sub update_network
next if $file eq "lo";
next if $file =~ /virbr\d/;
my $full_path = "$directory/$file";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { full_path => $full_path }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { full_path => $full_path }});
if (-d $full_path)
{
# Pull out the data I want. Note that some of these don't exist with virtio-net interfaces.
@@ -81,7 +84,7 @@ sub update_network
my $mtu = -e $full_path."/mtu" ? $anvil->Storage->read_file({file => $full_path."/mtu"}) : 0;
my $duplex = -e $full_path."/duplex" ? $anvil->Storage->read_file({file => $full_path."/duplex"}) : "unknown"; # full or half?
my $operational = -e $full_path."/operstate" ? $anvil->Storage->read_file({file => $full_path."/operstate"}) : "unknown"; # up or down
- my $speed = $link_state ? $anvil->Storage->read_file({file => $full_path."/speed", debug => 2}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
+ my $speed = $link_state ? $anvil->Storage->read_file({debug => 3, file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
my $media = "unknown";
my $type = "interface";
@@ -101,7 +104,7 @@ sub update_network
{
$ip_address = $anvil->data->{sys}{network}{interface}{$interface}{ip} ? $anvil->data->{sys}{network}{interface}{$interface}{ip} : "";
$subnet_mask = $anvil->data->{sys}{network}{interface}{$interface}{subnet} ? $anvil->data->{sys}{network}{interface}{$interface}{subnet} : "";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_address => $ip_address,
subnet_mask => $subnet_mask,
}});
@@ -114,7 +117,7 @@ sub update_network
{
# It's a slave.
$mac_address = $anvil->Storage->read_file({file => $mac_bond_file});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { mac_address => $mac_address }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { mac_address => $mac_address }});
}
# If this is a virtual interface, set some fake values that don't actually exist on
@@ -125,7 +128,7 @@ sub update_network
# Speed is "as fast as possible", so we'll record 100 Gbps, but that is really kind of arbitrary.
$speed = 100000 if ((not $speed) or ($speed eq "-1"));
$duplex = "full" if not $duplex;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
speed => $speed,
duplex => $duplex,
}});
@@ -134,7 +137,7 @@ sub update_network
if (not $link_state)
{
$speed = 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { speed => $speed }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { speed => $speed }});
}
# Is this a bond interface?
@@ -154,7 +157,7 @@ sub update_network
$mii_polling_interval = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/miimon"});
$up_delay = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/updelay"});
$down_delay = $anvil->Storage->read_file({file => "/sys/devices/virtual/net/".$interface."/bonding/downdelay"});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
active_slave => $active_slave,
bond_mode => $bond_mode,
mii_polling_interval => $mii_polling_interval,
@@ -168,13 +171,13 @@ sub update_network
# No, but it's slaved to one.
my $target = readlink($full_path."/master");
$bond_master = ($target =~ /^.*\/(.*)$/)[0];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
target => $target,
bond_master => $bond_master,
}});
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
active_slave => $active_slave,
bond_master => $bond_master,
bond_mode => $bond_mode,
@@ -207,7 +210,7 @@ sub update_network
# NOTE: This is probably 0 now... Though someday >100 Gbps will be reasonable
# and we'll need to change this.
$speed = 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { speed => $speed }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { speed => $speed }});
}
# Find the media, if possible.
@@ -219,14 +222,14 @@ sub update_network
if ($line =~ /Supported ports: \[ (.*?) \]/i)
{
$media = lc($1);
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { media => $media }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { media => $media }});
last;
}
}
# Record this interface
$anvil->data->{seen}{$type}{$interface} = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "seen::${type}::${interface}" => $anvil->data->{seen}{$type}{$interface} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "seen::${type}::${interface}" => $anvil->data->{seen}{$type}{$interface} }});
# Log
$anvil->data->{network}{interfaces}{by_name}{$interface} = {
@@ -249,7 +252,7 @@ sub update_network
type => $type,
up_delay => $up_delay,
};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"network::interfaces::by_name::${interface}::active_slave" => $anvil->data->{network}{interfaces}{by_name}{$interface}{active_slave},
"network::interfaces::by_name::${interface}::bond_mode" => $anvil->data->{network}{interfaces}{by_name}{$interface}{bond_mode},
"network::interfaces::by_name::${interface}::bond_master" => $anvil->data->{network}{interfaces}{by_name}{$interface}{bond_master},
@@ -276,7 +279,7 @@ sub update_network
# We need to record bonds first so that their UUIDs are available when recording interfaces.
foreach my $processing ("bond", "interface")
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { processing => $processing }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { processing => $processing }});
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{interfaces}{by_name}})
{
my $active_slave = $anvil->data->{network}{interfaces}{by_name}{$interface}{active_slave};
@@ -300,7 +303,7 @@ sub update_network
my $default_gateway = $anvil->data->{sys}{network}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{sys}{network}{interface}{$interface}{gateway};
my $dns = $anvil->data->{sys}{network}{interface}{$interface}{dns};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
active_slave => $active_slave,
bond_mode => $bond_mode,
bond_master => $bond_master,
@@ -328,7 +331,6 @@ sub update_network
if (($type eq $processing) && ($type eq "bond"))
{
my $bond_uuid = $anvil->Database->insert_or_update_bonds({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
bond_name => $interface,
@@ -345,13 +347,12 @@ sub update_network
bond_down_delay => $down_delay,
});
$anvil->data->{bond_by_name}{$interface} = $bond_uuid;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "bond_by_name::${interface}" => $anvil->data->{bond_by_name}{$interface} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "bond_by_name::${interface}" => $anvil->data->{bond_by_name}{$interface} }});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bond_uuid => $bond_uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bond_uuid => $bond_uuid }});
if (($bond_uuid) && ($ip_address))
{
my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
ip_address_on_type => $type,
@@ -368,17 +369,16 @@ sub update_network
if (($type eq $processing) && ($type eq "interface"))
{
my $say_bond_uuid = "";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bond_master => $bond_master }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bond_master => $bond_master }});
if (($bond_master) && ($anvil->data->{bond_by_name}{$bond_master}))
{
$say_bond_uuid = $anvil->data->{bond_by_name}{$bond_master};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"bond_by_name::${bond_master}" => $anvil->data->{bond_by_name}{$bond_master},
say_bond_uuid => $say_bond_uuid,
}});
}
my $network_interface_uuid = $anvil->Database->insert_or_update_network_interfaces({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
network_interface_bond_uuid => $say_bond_uuid,
@@ -392,13 +392,12 @@ sub update_network
network_interface_speed => $speed,
});
$anvil->data->{interface_by_name}{$interface} = $network_interface_uuid;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "interface_by_name::${interface}" => $anvil->data->{interface_by_name}{$interface} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "interface_by_name::${interface}" => $anvil->data->{interface_by_name}{$interface} }});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_interface_uuid => $network_interface_uuid }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_interface_uuid => $network_interface_uuid }});
if (($network_interface_uuid) && ($ip_address))
{
my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({
- debug => 2,
file => $THIS_FILE,
line => __LINE__,
ip_address_on_type => $type,
@@ -461,7 +460,7 @@ AND
bond_mac_address => $row->[10],
bond_operational => $row->[11],
};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"bonds::${bond_uuid}::bond_name" => $anvil->data->{bonds}{$bond_uuid}{bond_name},
"bonds::${bond_uuid}::bond_mode" => $anvil->data->{bonds}{$bond_uuid}{bond_mode},
"bonds::${bond_uuid}::bond_mtu" => $anvil->data->{bonds}{$bond_uuid}{bond_mtu},
@@ -516,7 +515,7 @@ AND
bridge_id => $row->[2],
bridge_stp_enabled => $row->[3],
};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"bridges::${bridge_uuid}::bridge_name" => $anvil->data->{bridges}{$bridge_uuid}{bridge_name},
"bridges::${bridge_uuid}::bridge_id" => $anvil->data->{bridges}{$bridge_uuid}{bridge_id},
"bridges::${bridge_uuid}::bridge_stp_enabled" => $anvil->data->{bridges}{$bridge_uuid}{bridge_stp_enabled},
@@ -556,7 +555,7 @@ AND
ORDER BY
modified_date DESC
;";
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0124", variables => { query => $query }});
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
@@ -585,7 +584,7 @@ ORDER BY
network_interface_bond_uuid => defined $row->[9] ? $row->[9] : 'NULL',
network_interface_bridge_uuid => defined $row->[10] ? $row->[10] : 'NULL',
};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"network_interfaces::${network_interface_uuid}::network_interface_mac_address" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_mac_address},
"network_interfaces::${network_interface_uuid}::network_interface_name" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_name},
"network_interfaces::${network_interface_uuid}::network_interface_speed" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_speed},
@@ -670,7 +669,7 @@ WHERE
my $ip_address_gateway = $row->[5];
my $ip_address_default_gateway = $row->[6];
my $ip_address_dns = $row->[7];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_address_on_type => $ip_address_on_type,
ip_address_on_uuid => $ip_address_on_uuid,
ip_address_address => $ip_address_address,
@@ -684,7 +683,7 @@ WHERE
my $found = 0;
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{sys}{network}{interface}})
{
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
interface => $interface,
ip_address_address => $ip_address_address,
"sys::network::interface::${interface}::ip" => $anvil->data->{sys}{network}{interface}{$interface}{ip},
@@ -692,29 +691,29 @@ WHERE
if ((defined $anvil->data->{sys}{network}{interface}{$interface}{ip}) && ($anvil->data->{sys}{network}{interface}{$interface}{ip} eq $ip_address_address))
{
$found = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { found => $found }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { found => $found }});
last;
}
}
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { found => $found }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { found => $found }});
if ($found)
{
my $say_on = "";
if ($ip_address_on_type eq "interface")
{
$say_on = $anvil->data->{network_interfaces}{$ip_address_on_uuid}{network_interface_name};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_on => $say_on }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_on => $say_on }});
}
elsif ($ip_address_on_type eq "bond")
{
$say_on = $anvil->data->{bonds}{$ip_address_on_uuid}{bond_name};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_on => $say_on }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_on => $say_on }});
}
elsif ($ip_address_on_type eq "bridge")
{
$say_on = $anvil->data->{bridges}{$ip_address_on_uuid}{bridge_name};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_on => $say_on }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_on => $say_on }});
}
$network_json .= " { \"address\":\"$ip_address_address\", \"on\":\"$say_on\", \"subnet\":\"$ip_address_subnet_mask\", \"gateway\":\"$ip_address_gateway\", \"default_gateway\":\"$ip_address_default_gateway\", \"dns\":\"$ip_address_dns\" },\n";
@@ -730,10 +729,10 @@ WHERE
$network_json =~ s/,$//s;
$network_json .= "]}\n";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_json => $network_json }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_json => $network_json }});
$network_xml .= "\n";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_xml => $network_xml }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }});
# Write the JSON file.
my $output_json = $anvil->data->{path}{directories}{html}."/status/network.json";
diff --git a/tools/anvil-update-system b/tools/anvil-update-system
index d937082f..5432977e 100755
--- a/tools/anvil-update-system
+++ b/tools/anvil-update-system
@@ -16,6 +16,9 @@
# 2 = The job UUID was passed, but it wasn't valid.
# 3 = It looks like the update failed, reset progress to '0'.
#
+# TODO:
+# - Use this to update local repos for when we get to the Install Manifest stage.
+#
use strict;
use warnings;
@@ -34,9 +37,10 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
# Read switches
-$anvil->data->{switches}{'job-uuid'} = "";
+$anvil->data->{switches}{'job-uuid'} = "";
$anvil->Get->switches;
# Log that we've started.
@@ -44,7 +48,7 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure =
# Connect to DBs.
$anvil->Database->connect;
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, exit.
@@ -54,12 +58,12 @@ if (not $anvil->data->{sys}{database}{connections})
}
# Did we get called with a job UUID? If not, try to find a pending job and take it.
-$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }});
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }});
if (not $anvil->data->{switches}{'job-uuid'})
{
# See if a job is waiting to run.
- $anvil->data->{switches}{job_uuid} = $anvil->Job->get_job_uuid({debug => 2, program => $THIS_FILE});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }});
+ $anvil->data->{switches}{job_uuid} = $anvil->Job->get_job_uuid({program => $THIS_FILE});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }});
}
if ($anvil->data->{switches}{'job-uuid'})
{
@@ -85,11 +89,11 @@ FROM
WHERE
job_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{switches}{'job-uuid'})."
;";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results,
count => $count,
}});
@@ -107,7 +111,7 @@ WHERE
$anvil->data->{jobs}{job_updated} = $results->[0]->[2];
$anvil->data->{jobs}{job_name} = $results->[0]->[3];
$anvil->data->{jobs}{job_status} = $results->[0]->[4];
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid},
"jobs::job_host_uuid" => $anvil->data->{jobs}{job_host_uuid},
"jobs::job_data" => $anvil->data->{jobs}{job_data},
@@ -131,14 +135,14 @@ update_progress($anvil, 1, "message_0058,!!downloaded!0!!,!!installed!0!!,!!veri
update_progress($anvil, 2, "message_0033");
# Make sure maintenance mode is enabled.
-$anvil->System->maintenance_mode({debug => 3, set => 1});
+$anvil->System->maintenance_mode({set => 1});
# Run the update
run_os_update($anvil);
# We're done updating
-my $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
-$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+my $reboot_needed = $anvil->System->reboot_needed();
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { reboot_needed => $reboot_needed }});
if ($reboot_needed)
{
update_progress($anvil, 100, "message_0039");
@@ -149,7 +153,7 @@ else
}
# Clear maintenance mode.
-$anvil->System->maintenance_mode({debug => 3, set => 0});
+$anvil->System->maintenance_mode({set => 0});
$anvil->nice_exit({exit_code => 0});
@@ -164,7 +168,7 @@ sub update_progress
my ($anvil, $progress, $message) = @_;
# Log the progress percentage.
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
progress => $progress,
message => $message,
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid},
@@ -173,7 +177,7 @@ sub update_progress
if ($anvil->data->{jobs}{job_uuid})
{
$anvil->Job->update_progress({
- debug => 2,
+ debug => 3,
progress => $progress,
message => $message,
job_uuid => $anvil->data->{jobs}{job_uuid},
@@ -199,7 +203,7 @@ sub run_os_update
my $verifying = 0;
my $output = "";
my $shell_call = $anvil->data->{path}{exe}{dnf}." clean expire-cache && ".$anvil->data->{path}{exe}{dnf}." -y update; ".$anvil->data->{path}{exe}{echo}." return_code:\$?";
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { shell_call => $shell_call }});
open (my $file_handle, $shell_call." 2>&1 |") or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
@@ -215,8 +219,8 @@ sub run_os_update
# Reboot will be needed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0199"});
- my $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+ my $reboot_needed = $anvil->System->reboot_needed({set => 1});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { reboot_needed => $reboot_needed }});
}
# If there were no updates, let the user know.
@@ -245,11 +249,11 @@ sub run_os_update
if ($line =~ /return_code:(\d+)$/)
{
my $return_code = $1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { return_code => $return_code }});
if ($return_code == 0)
{
$success = 1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { success => $success }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { success => $success }});
}
}
@@ -257,7 +261,7 @@ sub run_os_update
{
my $counted_lines = $1;
$to_update += $counted_lines;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
counted_lines => $counted_lines,
to_update => $to_update,
}});
@@ -266,7 +270,7 @@ sub run_os_update
if ($line =~ /Total download size: (.*)$/i)
{
my $update_size = $1;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { update_size => $update_size }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update_size => $update_size }});
# Ready to install, update to 5%. The next step will count up to 95%.
update_progress($anvil, $progress, "message_0035,!!size!$update_size!!");
@@ -278,7 +282,7 @@ sub run_os_update
$to_update *= 4;
$percent_step = $anvil->Convert->round({number => ($to_update / 90)});
$next_step = $percent_step;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
to_update => $to_update,
percent_step => $percent_step,
next_step => $next_step,
@@ -289,22 +293,22 @@ sub run_os_update
if (($percent_step) && (($line =~ /\(\d+\/\d+\): /) or ($line =~ /^Upgrading /i) or ($line =~ /^Installing /) or ($line =~ /^Cleanup /i) or ($line =~ /^Verifying /i)))
{
$counted_lines++;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { counted_lines => $counted_lines }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { counted_lines => $counted_lines }});
if ($line =~ /\(\d+\/\d+\): /)
{
$anvil->data->{counts}{downloaded}++;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "counts::downloaded" => $anvil->data->{counts}{downloaded} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "counts::downloaded" => $anvil->data->{counts}{downloaded} }});
}
if (($line =~ /^Upgrading /i) or ($line =~ /^Installing /))
{
$anvil->data->{counts}{installed}++;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "counts::installed" => $anvil->data->{counts}{installed} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "counts::installed" => $anvil->data->{counts}{installed} }});
}
if ($line =~ /^Verifying /i)
{
$anvil->data->{counts}{verified}++;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "counts::verified" => $anvil->data->{counts}{verified} }});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "counts::verified" => $anvil->data->{counts}{verified} }});
}
if ($counted_lines > $next_step)
@@ -316,7 +320,7 @@ sub run_os_update
next_step => $next_step,
progress => $progress,
}});
- next if $progress > 95;
+ $progress = 95 if $progress > 95;
update_progress($anvil, $progress, "");
}
@@ -325,14 +329,15 @@ sub run_os_update
# Update the progress if it's been more than a second since the last update.
if (time > $anvil->data->{sys}{last_update})
{
+ $progress = 95 if $progress > 95;
update_progress($anvil, $progress, "");
}
}
close $file_handle;
# Reload daemons to pick up any changed systemctl daemons.
- my $systemctl_output = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{systemctl}." daemon-reload", source => $THIS_FILE, line => __LINE__});
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { systemctl_output => $systemctl_output }});
+ my $systemctl_output = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{systemctl}." daemon-reload", source => $THIS_FILE, line => __LINE__});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { systemctl_output => $systemctl_output }});
# Did it work?
if (not $success)