* Fixed a bug in Job->clear() where it was not doing it's one job right.

* Updated System->generate_state_json() where when the full host name was short, it wouldn't set the short host name properly.
* Fixed a bug in 'tools/anvil-manage-power' where the node wouldn't mark the reboot as complete. Resolves issue #11.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 726a4374d1
commit 4489111a65
  1. 9
      Anvil/Tools/Job.pm
  2. 14
      Anvil/Tools/System.pm
  3. 2
      tools/anvil-daemon
  4. 6
      tools/anvil-manage-power

@ -108,14 +108,13 @@ sub clear
return(1);
}
$job_uuid = $anvil->Database->insert_or_update_jobs({
$job_uuid = $anvil->Job->update_progress({
debug => $debug,
file => $THIS_FILE,
line => __LINE__,
debug => $debug,
update_progress_only => 1,
progress => 0,
message => "clear",
job_uuid => $job_uuid,
job_picked_up_by => 0,
job_progress => 0,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});

@ -1222,7 +1222,7 @@ sub generate_state_json
foreach my $host_uuid (keys %{$anvil->data->{machine}{host_uuid}})
{
my $host_name = $anvil->data->{machine}{host_uuid}{$host_uuid}{hosts}{host_name};
my $short_host_name = ($host_name =~ /^(.*?)\./)[0];
my $short_host_name = $host_name =~ /\./ ? ($host_name =~ /^(.*?)\./)[0] : $host_name;
my $host_type = $anvil->data->{machine}{host_uuid}{$host_uuid}{hosts}{host_type};
my $host_key = $anvil->data->{machine}{host_uuid}{$host_uuid}{hosts}{host_key};
my $configured = defined $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} ? $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} : 0;
@ -2766,7 +2766,9 @@ sub reboot_needed
{
# Set
$anvil->Database->insert_or_update_variables({
debug => 2,
debug => $debug,
file => $THIS_FILE,
line => __LINE__,
variable_name => "reboot::needed",
variable_value => "1",
variable_default => "0",
@ -2774,14 +2776,15 @@ sub reboot_needed
variable_section => "system",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
elsif ($set eq "0")
{
# Clear
$anvil->Database->insert_or_update_variables({
debug => 2,
debug => $debug,
file => $THIS_FILE,
line => __LINE__,
variable_name => "reboot::needed",
variable_value => "0",
variable_default => "0",
@ -2789,7 +2792,6 @@ sub reboot_needed
variable_section => "system",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
else
@ -2802,6 +2804,8 @@ sub reboot_needed
my ($reboot_needed, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
debug => $debug,
file => $THIS_FILE,
line => __LINE__,
variable_name => "reboot::needed",
variable_source_table => "hosts",
variable_source_uuid => $anvil->Get->host_uuid,

@ -1129,7 +1129,7 @@ sub run_jobs
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}, my $return_code) = $anvil->System->call({
debug => 3,
debug => 2,
background => 1,
stdout_file => "/tmp/anvil.job.".$job_uuid.".stdout",
stderr_file => "/tmp/anvil.job.".$job_uuid.".stderr",

@ -66,6 +66,9 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->nice_exit({exit_code => 1});
}
# Clear the job in case a previous call failed.
$anvil->Job->clear({debug => 2, job_uuid => $anvil->data->{switches}{'job-uuid'}}) if $anvil->data->{switches}{'job-uuid'};
# Are we being asked to reboot or power off?
if ($anvil->data->{switches}{'reboot'})
{
@ -231,7 +234,6 @@ sub do_poweroff
if ($job_uuid)
{
$anvil->Job->clear({job_uuid => $job_uuid});
$anvil->Job->update_progress({
debug => 2,
progress => $percent,
@ -242,7 +244,7 @@ sub do_poweroff
# Make sure the 'reboot needed' flag is set. When 'anvil-daemon' starts, it will use this to confirm
# that it is starting post-reboot and clear it.
$reboot_needed = $anvil->System->reboot_needed({set => 1});
$reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
# Now do the deed.
my $shell_call = $anvil->data->{path}{exe}{systemctl}." ".$task;

Loading…
Cancel
Save