* Adding database peers (local and bidirectional) now works!

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 7bd65f65e5
commit c6e781d80b
  1. 1
      Anvil/Tools.pm
  2. 2
      Anvil/Tools/Account.pm
  3. 8
      Anvil/Tools/Database.pm
  4. 12
      cgi-bin/striker
  5. 11
      notes
  6. 1
      share/words.xml
  7. 1
      tools/anvil-configure-striker
  8. 9
      tools/anvil-manage-striker-peers

@ -610,6 +610,7 @@ sub _anvil_version
my $self = shift; my $self = shift;
my $anvil = $self; my $anvil = $self;
$anvil->data->{HOST}{ANVIL_VERSION} = "" if not defined $anvil->data->{HOST}{ANVIL_VERSION};
if ($anvil->data->{HOST}{ANVIL_VERSION} eq "") if ($anvil->data->{HOST}{ANVIL_VERSION} eq "")
{ {
# Try to read the local Anvil! version. # Try to read the local Anvil! version.

@ -501,6 +501,7 @@ sub read_cookies
if ($count < 1) if ($count < 1)
{ {
# The user in the cookie isn't in the database. The user was deleted? # The user in the cookie isn't in the database. The user was deleted?
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout(); $anvil->Account->logout();
# Record the error message for the user. # Record the error message for the user.
@ -560,6 +561,7 @@ sub read_cookies
#die; #die;
# The user's cookie is invalid, log the user out. # The user's cookie is invalid, log the user out.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout(); $anvil->Account->logout();
# Record the error message for the user. # Record the error message for the user.

@ -5436,8 +5436,12 @@ sub _find_behind_databases
# 'modified_date' entries, or no entries in one DB with entries in the other (as can happen with a # 'modified_date' entries, or no entries in one DB with entries in the other (as can happen with a
# newly setup db). # newly setup db).
$anvil->data->{sys}{database}{check_tables} = []; $anvil->data->{sys}{database}{check_tables} = [];
# The 'hosts' table always has to be the first table sync'ed as just about everything else references it.
push @{$anvil->data->{sys}{database}{check_tables}}, "hosts";
foreach my $table (@{$anvil->data->{sys}{database}{core_tables}}) foreach my $table (@{$anvil->data->{sys}{database}{core_tables}})
{ {
next if $table eq "hosts";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { table => $table }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { table => $table }});
push @{$anvil->data->{sys}{database}{check_tables}}, $table; push @{$anvil->data->{sys}{database}{check_tables}}, $table;
} }
@ -5450,6 +5454,8 @@ sub _find_behind_databases
} }
} }
# Preset all tables to have an initial 'modified_date' of 0. # Preset all tables to have an initial 'modified_date' of 0.
foreach my $table (sort {$a cmp $b} @{$anvil->data->{sys}{database}{check_tables}}) foreach my $table (sort {$a cmp $b} @{$anvil->data->{sys}{database}{check_tables}})
{ {
@ -5571,7 +5577,7 @@ ORDER BY
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0106", variables => { uuid => $uuid }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0106", variables => { uuid => $uuid }});
# Mark it as behind. # Mark it as behind.
$anvil->Database->_mark_database_as_behind({uuid => $uuid}); $anvil->Database->_mark_database_as_behind({debug => $debug, uuid => $uuid});
last; last;
} }
} }

@ -168,7 +168,13 @@ sub process_task
# Is the user trying to log in? # Is the user trying to log in?
my $logged_in = 0; my $logged_in = 0;
if ((defined $anvil->data->{cgi}{login}) && ($anvil->data->{cgi}{login}{value})) $anvil->data->{cgi}{login}{value} = "" if not defined $anvil->data->{cgi}{login}{value};
$anvil->data->{cgi}{logout}{value} = "" if not defined $anvil->data->{cgi}{logout}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"cgi::login::value" => $anvil->data->{cgi}{login}{value},
"cgi::logout::value" => $anvil->data->{cgi}{logout}{value},
}});
if ($anvil->data->{cgi}{login}{value})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::login::value" => $anvil->data->{cgi}{login}{value} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::login::value" => $anvil->data->{cgi}{login}{value} }});
@ -181,9 +187,10 @@ sub process_task
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { logged_in => $logged_in }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { logged_in => $logged_in }});
} }
} }
elsif ((defined $anvil->data->{cgi}{logout}) && ($anvil->data->{cgi}{logout}{value})) elsif ($anvil->data->{cgi}{logout}{value})
{ {
# Bye now! # Bye now!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout(); $anvil->Account->logout();
} }
else else
@ -313,6 +320,7 @@ sub process_power
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "form::body" => $anvil->data->{form}{body} }});
# Log the user out, just to be safe. # Log the user out, just to be safe.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout(); $anvil->Account->logout();
} }
else else

11
notes

@ -1,3 +1,14 @@
DB stuff;
Dump;
su - postgres -c "pg_dump anvil" > /anvil.out
Reload the DB;
su - postgres -c "dropdb anvil" && su - postgres -c "createdb --owner admin anvil" && su - postgres -c "psql anvil < /anvil.out"
su - postgres -c "psql anvil"
All systems have a UUID, even VMs. Use that for system UUID in the future. All systems have a UUID, even VMs. Use that for system UUID in the future.
https://access.redhat.com/solutions/2841131 - How to write a NetworkManager dispatcher script to apply ethtool commands? https://access.redhat.com/solutions/2841131 - How to write a NetworkManager dispatcher script to apply ethtool commands?

@ -363,6 +363,7 @@ The database connection error was:
<key name="log_0212">We've been asked to have the new peer add us. We will now wait for the peer to show up in the 'hosts' table and then request the job for it to add us.</key> <key name="log_0212">We've been asked to have the new peer add us. We will now wait for the peer to show up in the 'hosts' table and then request the job for it to add us.</key>
<key name="log_0213">The peer: [#!variable!peer_uuid!#] is not yet in 'hosts', continuing to wait.</key> <key name="log_0213">The peer: [#!variable!peer_uuid!#] is not yet in 'hosts', continuing to wait.</key>
<key name="log_0214">The peer: [#!variable!peer_name!#] is now in 'hosts', proceeding.</key> <key name="log_0214">The peer: [#!variable!peer_name!#] is now in 'hosts', proceeding.</key>
<key name="log_0215">Logging the user: [#!data!sys::users::user_name!#] out.</key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. --> <!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<key name="t_0000">Test</key> <key name="t_0000">Test</key>

@ -93,6 +93,7 @@ if (not $anvil->data->{switches}{'no-reboot'})
# Reboot, after waiting a few seconds to let the user's browser pick up the last messages in # Reboot, after waiting a few seconds to let the user's browser pick up the last messages in
# jobs.json. We'll also log the user out, in case we were re-configuring. # jobs.json. We'll also log the user out, in case we were re-configuring.
sleep 5; sleep 5;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout; $anvil->Account->logout;
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{'anvil-manage-power'}." --reboot -y"}); $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{'anvil-manage-power'}." --reboot -y"});
} }

@ -24,7 +24,6 @@
# /usr/sbin/anvil-manage-striker-peers --remove --host-uuid e20c3f10-c35d-4543-b5e6-8a373f27977a # /usr/sbin/anvil-manage-striker-peers --remove --host-uuid e20c3f10-c35d-4543-b5e6-8a373f27977a
# #
use strict; use strict;
use warnings; use warnings;
use Anvil::Tools; use Anvil::Tools;
@ -569,10 +568,10 @@ sub process_entry
} }
# Now add the job. # Now add the job.
my $host_uuid = $anvil->Get->host_uuid; my $our_host_uuid = $anvil->Get->host_uuid;
my $sql_password = $anvil->data->{database}{$host_uuid}{password}; my $sql_password = $anvil->data->{database}{$our_host_uuid}{password};
my $job_command = $add_peer_command; my $job_command = $add_peer_command;
my $job_data = "password=".$sql_password; my $job_data = "password=".$sql_password;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { job_command => $job_command }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { job_command => $job_command }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { job_data => $job_data }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { job_data => $job_data }});

Loading…
Cancel
Save