* Added support to reconfigure a Striker system.

* Started adding support for updating the striker (and later, all) systems. This will be handled by the in-progress tools/anvil-update-system program.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 28f3aaae43
commit a63bfb0799
  1. 69
      cgi-bin/striker
  2. 5
      html/skins/alteeve/main.css
  3. 62
      html/skins/alteeve/striker.html
  4. 3
      share/words.xml
  5. 114
      tools/anvil-update-system

@ -226,6 +226,14 @@ sub process_task
{ {
process_sync_page($anvil); process_sync_page($anvil);
} }
elsif ($anvil->data->{cgi}{task}{value} eq "reconfig")
{
process_reconfig_page($anvil);
}
elsif ($anvil->data->{cgi}{task}{value} eq "update")
{
process_update($anvil);
}
else else
{ {
# The 'back' goes home # The 'back' goes home
@ -256,6 +264,67 @@ sub process_task
return(0); return(0);
} }
# This handles updating this Striker.
sub process_update
{
my ($anvil) = @_;
### NOTE: This doesn't update Striker (the Alteeve) stack yet, just the base OK.
$anvil->data->{cgi}{confirm}{value} = "" if not defined $anvil->data->{cgi}{confirm}{value};
if ($anvil->data->{cgi}{confirm}{value})
{
# Request the job and take the system offline until it's done.
# $anvil->Database->insert_or_update_variables({
# variable_name => "system::configured",
# variable_source_uuid => $anvil->Get->host_uuid,
# variable_source_table => "hosts",
# variable_value => 0,
# update_value_only => 1,
# });
# Done.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "update-requested"});
}
else
{
# Show the screen the confirm the addition.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "confirm-update"});
}
return(0);
}
# This handles reconfiguring the Striker system.
sub process_reconfig_page
{
my ($anvil) = @_;
# Later, this will let each piece be recondigured. For now, it simple reset the "configured flag so
# the next load will trigger the initial config again.
$anvil->data->{cgi}{confirm}{value} = "" if not defined $anvil->data->{cgi}{confirm}{value};
if ($anvil->data->{cgi}{confirm}{value})
{
# Update the configured variable
$anvil->Database->insert_or_update_variables({
variable_name => "system::configured",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
variable_value => 0,
update_value_only => 1,
});
# Done.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "reconfig-done"});
}
else
{
# Show the screen the confirm the addition.
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "confirm-reconfig"});
}
return(0);
}
# This handles tasks related to setting up peer Strikers. # This handles tasks related to setting up peer Strikers.
sub process_sync_page sub process_sync_page
{ {

@ -269,6 +269,11 @@ td {
text-align: center; text-align: center;
} }
.button {
padding: 10px 5px;
text-align: center;
}
.icon_button { .icon_button {
padding-top: 30px; padding-top: 30px;
vertical-align: top; vertical-align: top;

@ -61,8 +61,66 @@
</table> </table>
</td> </td>
</tr> </tr>
</table>
<!-- end confirm-new-peer --> <!-- end confirm-new-peer -->
<!-- start confirm-reconfig -->
<table align="center">
<form name="confirm-reconfig" action="" method="post">
<div id="confirm-reconfig">
<tr>
<td class="menu_title">
#!string!striker_0078!#
</td>
</tr>
<tr>
<td class="menu_details">
#!string!striker_0083!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td class="button_cell" colspan="2">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#">
</td>
</tr>
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
<input type="hidden" name="task" id="task" value="#!data!cgi::task::value!#">
<input type="hidden" name="save" id="save" value="#!data!cgi::save::value!#">
</form>
</div>
</table>
<!-- end confirm-reconfig -->
<!-- start reconfig-done -->
<table>
<tr>
<td class="menu_title">
#!string!striker_0084!#
</td>
</tr>
<tr>
<td class="menu_details">
#!string!striker_0085!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
<a href="/" class="button">#!string!striker_0053!#</a>
</td>
</tr>
</table>
<!-- end reconfig-done -->
<!-- start striker-login --> <!-- start striker-login -->
<table class="login"> <table class="login">
<form name="striker_login" action="" method="post"> <form name="striker_login" action="" method="post">
@ -156,10 +214,10 @@
</tr> </tr>
<tr> <tr>
<td rowspan="2" class="icon_button"> <td rowspan="2" class="icon_button">
<a href="?striker=true&task=update"><img src="#!data!skin::url!#/images/striker_configure.png" class="top_icon" ></a> <a href="?striker=true&task=reconfig"><img src="#!data!skin::url!#/images/striker_configure.png" class="top_icon" ></a>
</td> </td>
<td class="menu_title"> <td class="menu_title">
<a href="?striker=true&task=update">#!string!striker_0058!#</a> <a href="?striker=true&task=reconfig">#!string!striker_0058!#</a>
</td> </td>
</tr> </tr>
<tr> <tr>

@ -410,6 +410,9 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_0080">Ping before connect</key> <key name="striker_0080">Ping before connect</key>
<key name="striker_0081">The test connection was successful. When saved, the resynchronization process might take a few minutes, and cause maintenance periods where some features are offline until complete.</key> <key name="striker_0081">The test connection was successful. When saved, the resynchronization process might take a few minutes, and cause maintenance periods where some features are offline until complete.</key>
<key name="striker_0082">Confirm</key> <key name="striker_0082">Confirm</key>
<key name="striker_0083">Would you like to reconfigure this machine? If you confirm, Striker will re-run the initial configuration. Connections to peers and database data will be retained.</key>
<key name="striker_0084">Confirmed</key>
<key name="striker_0085">This Striker has been marked as reconfigured. Reload to start the confguration process.</key>
<!-- Strings used by jobs --> <!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key> <key name="job_0001">Configure Network</key>

@ -0,0 +1,114 @@
#!/usr/bin/perl
#
# This updates the host system.
# NOTE: This doesn't update the Anvil! software stack yet, just the OS.
#
# - On Striker; This will take the system offline and then run 'dnf -y update'.
# - On Nodes; This will do nothing until all servers are off the node. Then the node will be withdrawn,
# updated and then rejoin the cluster.
# - On DR; This will do nothing until no servers are running, then it will update the system.
#
# In all cases, the system will be rebooted
#
use strict;
use warnings;
use Anvil::Tools;
# Disable buffering
$| = 1;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
if (($running_directory =~ /^\./) && ($ENV{PWD}))
{
$running_directory =~ s/^\./$ENV{PWD}/;
}
my $anvil = Anvil::Tools->new({log_level => 1, log_secure => 1});
$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", variables => { "sys::db_connections" => $anvil->data->{sys}{db_connections} }});
if (not $anvil->data->{sys}{db_connections})
{
# No databases, exit.
print $anvil->Words->string({key => "error_0003"})."\n";
$anvil->nice_exit({exit_code => 2});
}
# Did we get called with a job UUID?
$anvil->data->{jobs}{job_uuid} = defined $anvil->data->{switches}{'job-uuid'} ? $anvil->data->{switches}{'job-uuid'} : "";
update_progress($anvil, 1);
run_os_update($anvil);
$anvil->nice_exit({exit_code => 0});
#############################################################################################################
# Functions #
#############################################################################################################
# This updates the progress if we were called with a job UUID.
sub update_progress
{
my ($anvil, $progress) = @_;
if ($anvil->data->{jobs}{job_uuid})
{
my $query = "
UPDATE
jobs
SET
job_picked_up_by = ".$anvil->data->{sys}{use_db_fh}->quote($$).",
job_progress = ".$progress.",
modified_date = ".$anvil->data->{sys}{use_db_fh}->quote($anvil->data->{sys}{db_timestamp})."
WHERE
job_uuid = ".$anvil->data->{sys}{use_db_fh}->quote($job_uuid)."
";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
}
return(0);
}
# This updates the OS.
sub run_os_update
{
my ($anvil) = @_;
my $stdout_file = "/tmp/os_update.stdout";
my $stderr_file = "/tmp/os_update.stderr";
my $shell_call = $anvil->data->{path}{exe}{dnf}." clean expire-cache && ".$anvil->data->{path}{exe}{dnf}." -y update";
my $process = $anvil->System->call({
debug => 2,
background => 1,
stdout_file => $stdout_file,
stderr_file => $stderr_file,
shell_call => $job_command." --job-uuid ".$job_uuid,
source => $THIS_FILE,
line => __LINE__,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { process => $process }});
# Record our PID
my $pid = $anvil->data->{jobs}{handles}{$job_uuid}->pid();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { pid => $pid }});
my $query = "
UPDATE
jobs
SET
job_picked_up_by = ".$anvil->data->{sys}{use_db_fh}->quote($pid).",
modified_date = ".$anvil->data->{sys}{use_db_fh}->quote($anvil->data->{sys}{db_timestamp})."
WHERE
job_uuid = ".$anvil->data->{sys}{use_db_fh}->quote($job_uuid)."
";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
return(0);
};
Loading…
Cancel
Save