diff --git a/Anvil/Tools/ScanCore.pm b/Anvil/Tools/ScanCore.pm index e6807fcc..5c2a58fa 100644 --- a/Anvil/Tools/ScanCore.pm +++ b/Anvil/Tools/ScanCore.pm @@ -2415,7 +2415,7 @@ LIMIT 1;"; $stop_reason = "unknown"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { stop_reason => $stop_reason }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0565", variables => { host_name => $host_name }}); - next; + } if ($stop_reason eq "user") @@ -2424,7 +2424,7 @@ LIMIT 1;"; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0566", variables => { host_name => $host_name }}); next; } - elsif ($stop_reason eq "power") + elsif (($stop_reason eq "power") or ($stop_reason eq "unknown")) { # Check now if the power is OK $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0567", variables => { host_name => $host_name }}); diff --git a/share/words.xml b/share/words.xml index 43fbafb9..91751fe8 100644 --- a/share/words.xml +++ b/share/words.xml @@ -1786,7 +1786,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is: The host: [#!variable!host_name!#] is up, no need to check if it needs booting. The host: [#!variable!host_name!#] couldn't be reached directly, but IPMI reports that it is up. Could the IPMI BMC be hung or unplugged? The host: [#!variable!host_name!#] is off. Will check now if it should be booted. - The host: [#!variable!host_name!#] has no stop reason, so we'll leave it off. + The host: [#!variable!host_name!#] has no stop reason, so we'll boot it up in case it lost power without warning. The host: [#!variable!host_name!#] was stopped by the user, so we'll leave it off. The host: [#!variable!host_name!#] was powered off because of power loss. Checking to see if it is now safe to restart it. The host: [#!variable!host_name!#] was powered off because of thermal issues. Checking to see if it is now safe to restart it. diff --git a/tools/anvil-manage-server b/tools/anvil-manage-server index 7fc2ae80..07c37325 100755 --- a/tools/anvil-manage-server +++ b/tools/anvil-manage-server @@ -819,11 +819,7 @@ sub interactive_configure_storage anvil_uuid => $anvil_uuid, path => $this_path, }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - 's1:storage_group_name' => $storage_group_name, - 's2:storage_group_uuid' => $storage_group_uuid, - 's3:this_storage_group_uuid' => $this_storage_group_uuid, - }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { this_storage_group_uuid => $this_storage_group_uuid }}); if (($this_storage_group_uuid) && ($storage_group_uuid eq $this_storage_group_uuid)) { @@ -837,8 +833,7 @@ sub interactive_configure_storage } $lines += 2; - print "[ ".$index." ] - Name: \"".$storage_group_name."\"\n"; - print " - Size: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size})."], Free: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $free_size})."]\n"; + print "[ ".$index." ] - Name: \"".$storage_group_name."\" - Size: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size})."], Free: [".$anvil->Convert->bytes_to_human_readable({'bytes' => $free_size})."]\n"; my $path_count = keys %{$paths}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { path_count => $path_count }}); diff --git a/tools/anvil-safe-stop b/tools/anvil-safe-stop index bb3c0d30..6f30a1c8 100755 --- a/tools/anvil-safe-stop +++ b/tools/anvil-safe-stop @@ -27,17 +27,28 @@ $| = 1; my $anvil = Anvil::Tools->new(); $anvil->data->{switches}{'job-uuid'} = ""; +$anvil->data->{switches}{'poweroff'} = ""; $anvil->data->{switches}{'power-off'} = ""; # By default, the node is withdrawn. With this switch, the node will power off as well. $anvil->data->{switches}{'stop-reason'} = ""; # Optionally used to set 'system::stop_reason' reason for this host. Valid values are 'user', 'power' and 'thermal'. $anvil->data->{switches}{'stop-servers'} = ""; # Default behaviour is to migrate servers to the peer, if the peer is up. This overrides that and forces hosted servers to shut down. $anvil->Get->switches; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'switches::job-uuid' => $anvil->data->{switches}{'job-uuid'}, + 'switches::poweroff' => $anvil->data->{switches}{'poweroff'}, 'switches::power-off' => $anvil->data->{switches}{'power-off'}, 'switches::stop-reason' => $anvil->data->{switches}{'stop-reason'}, 'switches::stop-servers' => $anvil->data->{switches}{'stop-servers'}, }}); +# Let 'poweroff' work as a mis-spell of 'power-off' +if (($anvil->data->{switches}{'poweroff'}) && (not $anvil->data->{switches}{'power-off'})) +{ + $anvil->data->{switches}{'power-off'} = $anvil->data->{switches}{'poweroff'}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 'switches::power-off' => $anvil->data->{switches}{'power-off'}, + }}); +} + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0115", variables => { program => $THIS_FILE }}); # Make sure we're running as 'root' @@ -121,6 +132,9 @@ if (not $anvil->data->{sys}{anvil_uuid}) if (not $anvil->data->{switches}{'stop-reason'}) { $anvil->data->{switches}{'stop-reason'} = "user"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + 'switches::stop-reason' => $anvil->data->{switches}{'stop-reason'}, + }}); } # Migrate or stop the servers, if any servers are running here. @@ -145,6 +159,25 @@ if ($anvil->data->{switches}{'power-off'}) $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0325"}); $anvil->Job->update_progress({progress => 100, message => "job_0325"}); + # Set the stop reason. + if ($anvil->data->{switches}{'stop-reason'}) + { + if ($anvil->data->{switches}{'stop-reason'} eq "none") + { + $anvil->data->{switches}{'stop-reason'} = ""; + } + my $variable_uuid = $anvil->Database->insert_or_update_variables({ + variable_name => 'system::stop_reason', + variable_value => $anvil->data->{switches}{'stop-reason'}, + variable_default => '', + variable_description => 'striker_0279', + variable_section => 'system', + variable_source_uuid => $anvil->Get->host_uuid(), + variable_source_table => 'hosts', + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { variable_uuid => $variable_uuid }}); + } + my $shell_call = $anvil->data->{path}{exe}{systemctl}." poweroff"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});