Added more job updates to anvil-manage-power.

* This is a test to see if the job waiting for the uptime to be 300s,
  leaving the job_progress as 0, was causing the job to be repeatedly
  called.
* This is related to issue #479

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 1 year ago
parent 5b286f2696
commit 582a8b292c
  1. 2
      share/words.xml
  2. 35
      tools/anvil-manage-power

@ -3157,6 +3157,8 @@ Proceed? [y/N]</key>
<key name="message_0348">Available Storage Groups;</key>
<key name="message_0349">- #!variable!storage_group_name!#, free space: #!variable!free_space!#, UUID: #!variable!storage_group_uuid!#</key>
<key name="message_0350">Preparing to managing storage for a server.</key>
<key name="message_0351">Running checks before processing power request...</key>
<key name="message_0352">The job to: [#!variable!task!#] this host has been picked up.</key>
<!-- Translate names (protocols, etc) -->
<key name="name_0001">Normal Password</key> <!-- none in mail-server -->

@ -67,7 +67,19 @@ if (not $anvil->data->{sys}{database}{connections})
}
# 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'};
if ($anvil->data->{switches}{'job-uuid'})
{
$anvil->Job->clear({debug => 2, job_uuid => $anvil->data->{switches}{'job-uuid'}});
my $task = $anvil->data->{switches}{'reboot'} ? "log_0226" : "log_0225";
$anvil->Job->update_progress({
debug => 2,
progress => 1,
message => "message_0352",
job_uuid => $anvil->data->{switches}{'job-uuid'},
log_level => 1,
variables => { task => $task },
});
}
# Are we being asked to reboot or power off?
if ($anvil->data->{switches}{'reboot'})
@ -188,6 +200,17 @@ sub do_poweroff
my ($anvil, $task) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { task => $task }});
if ($anvil->data->{switches}{'job-uuid'})
{
$anvil->Job->update_progress({
debug => 2,
progress => 10,
message => "message_0351",
log_level => 1,
job_uuid => $anvil->data->{switches}{'job-uuid'},
});
}
# In case we're being called by another job, we'll sleep for a few second to let those close out.
sleep 3;
@ -208,6 +231,7 @@ sub do_poweroff
if (($uptime) && ($uptime < 300))
{
# We'll wait until the system has been running for five minutes.
my $difference = 300 - $uptime;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0224", variables => {
task => $task eq "poweroff" ? "#!string!log_0225!#" : "#!string!log_0226!#",
@ -287,10 +311,11 @@ sub do_poweroff
if ($job_uuid)
{
$anvil->Job->update_progress({
debug => 2,
progress => 100,
message => $say_task,
job_uuid => $job_uuid,
debug => 2,
progress => 100,
message => $say_task,
log_level => 1,
job_uuid => $job_uuid,
});
}

Loading…
Cancel
Save