* Updated System->check_if_configured() to record that a host is configured in /etc/anvil to make the system auto-mark as configured if the host is removed from the DB (or, more specifically, variables -> system::configured is lost).

* Updated Database->get_anvils() to record dr_links to reference DR hosts to Anvil! systems.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 2 years ago
parent f9ca6fb170
commit 9194eb3d09
  1. 3
      Anvil/Tools.pm
  2. 30
      Anvil/Tools/Database.pm
  3. 49
      Anvil/Tools/System.pm
  4. 37
      tools/anvil-daemon
  5. 2
      tools/anvil-manage-files

@ -1074,10 +1074,11 @@ sub _set_paths
'.htpasswd' => "/etc/httpd/.htpasswd", '.htpasswd' => "/etc/httpd/.htpasswd",
'chrony.conf' => "/etc/chrony.conf", 'chrony.conf' => "/etc/chrony.conf",
group => "/etc/group", group => "/etc/group",
issue => "/etc/issue",
httpd_conf => "/etc/httpd/conf/httpd.conf", httpd_conf => "/etc/httpd/conf/httpd.conf",
host_configured => "/etc/anvil/host.configured",
host_ssh_key => "/etc/ssh/ssh_host_ecdsa_key.pub", host_ssh_key => "/etc/ssh/ssh_host_ecdsa_key.pub",
host_uuid => "/etc/anvil/host.uuid", host_uuid => "/etc/anvil/host.uuid",
issue => "/etc/issue",
network_cache => "/tmp/network_cache.anvil", network_cache => "/tmp/network_cache.anvil",
passwd => "/etc/passwd", passwd => "/etc/passwd",
'redhat-release' => "/etc/redhat-release", 'redhat-release' => "/etc/redhat-release",

@ -2650,6 +2650,9 @@ sub get_anvils
$anvil->Database->get_files({debug => $debug}); $anvil->Database->get_files({debug => $debug});
$anvil->Database->get_file_locations({debug => $debug}); $anvil->Database->get_file_locations({debug => $debug});
# Also pull in DRs so we can link them.
$anvil->Database->get_dr_links({debug => $debug});
my $query = " my $query = "
SELECT SELECT
anvil_uuid, anvil_uuid,
@ -2759,6 +2762,7 @@ WHERE
"anvils::host_uuid::${anvil_node2_host_uuid}::role" => $anvil->data->{anvils}{host_uuid}{$anvil_node2_host_uuid}{role}, "anvils::host_uuid::${anvil_node2_host_uuid}::role" => $anvil->data->{anvils}{host_uuid}{$anvil_node2_host_uuid}{role},
}}); }});
} }
### TODO: Remove this once the switch over to 'dr_links' is done.
if ($anvil_dr1_host_uuid) if ($anvil_dr1_host_uuid)
{ {
$anvil->data->{anvils}{host_uuid}{$anvil_dr1_host_uuid}{anvil_name} = $anvil_name; $anvil->data->{anvils}{host_uuid}{$anvil_dr1_host_uuid}{anvil_name} = $anvil_name;
@ -2812,6 +2816,32 @@ WHERE
"anvils::anvil_uuid::${anvil_uuid}::file_name::${file_name}::file_uuid" => $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid}, "anvils::anvil_uuid::${anvil_uuid}::file_name::${file_name}::file_uuid" => $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid},
}}); }});
} }
# Process DR hosts this Anvil! is allowed to use.
if (exists $anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid})
{
foreach my $dr_link_host_uuid (sort {$a cmp $b} keys %{$anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid}{dr_link_host_uuid}})
{
my $dr_link_uuid = $anvil->data->{dr_links}{by_anvil_uuid}{$anvil_uuid}{dr_link_host_uuid}{$dr_link_host_uuid}{dr_link_uuid};
my $dr_link_note = $anvil->data->{dr_links}{dr_link_uuid}{$dr_link_uuid}{dr_link_note};
my $dr_link_short_host_name = $anvil->data->{hosts}{host_uuid}{$dr_link_host_uuid}{short_host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:dr_link_host_uuid" => $dr_link_host_uuid,
"s2:dr_link_uuid" => $dr_link_uuid,
"s3:dr_link_note" => $dr_link_note,
"s4:dr_link_short_host_name" => $dr_link_short_host_name,
}});
next if $dr_link_note eq "DELETED";
$anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{dr_host}{$dr_link_host_uuid}{dr_link_uuid} = $dr_link_uuid;
$anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{dr_host}{$dr_link_host_uuid}{short_host_name} = $dr_link_short_host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:anvils::anvil_uuid::${anvil_uuid}::dr_host::${dr_link_host_uuid}::dr_link_uuid" => $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{dr_host}{$dr_link_host_uuid}{dr_link_uuid},
"s2:anvils::anvil_uuid::${anvil_uuid}::dr_host::${dr_link_host_uuid}::short_host_name" => $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{dr_host}{$dr_link_host_uuid}{short_host_name},
}});
}
}
} }
return(0); return(0);

@ -605,6 +605,55 @@ sub check_if_configured
$configured = 0 if not defined $configured; $configured = 0 if not defined $configured;
$configured = 0 if $configured eq ""; $configured = 0 if $configured eq "";
if ((not $configured) && (-f $anvil->data->{path}{data}{host_configured}))
{
# See if there's a configured file.
my $body = $anvil->Storage->read_file({debug => $debug, file => $anvil->data->{path}{data}{host_configured}});
foreach my $line (split/\n/, $body)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
if ($line =~ /^(.*)=(.*)$/)
{
my $variable = $anvil->Words->clean_spaces({string => $1});
my $value = $anvil->Words->clean_spaces({string => $2});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
variable => $variable,
value => $value,
}});
if (($variable eq "system::configured") && ($value eq "1"))
{
# Write the database entry.
my $variable_uuid = $anvil->Database->insert_or_update_variables({
variable_name => "system::configured",
variable_value => 1,
variable_default => "",
variable_description => "striker_0048",
variable_section => "system",
variable_source_uuid => $anvil->data->{sys}{host_uuid},
variable_source_table => "hosts",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_uuid => $variable_uuid }});
# mark it as configured.
$configured = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { configured => $configured }});
}
}
}
}
if (($configured) && (not -f $anvil->data->{path}{data}{host_configured}))
{
my $failed = $anvil->Storage->write_file({
debug => $debug,
file => $anvil->data->{path}{data}{host_configured},
body => "system::configured = 1\n",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { failed => $failed }});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { configured => $configured }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { configured => $configured }});
return($configured); return($configured);
} }

@ -20,6 +20,8 @@
# - # -
# - Increase DRBD's default timeout # - Increase DRBD's default timeout
# - Check for and enable persistent journald logging # - Check for and enable persistent journald logging
# -
# - Record that a machine is configured /etc/anvil/host.is_configred
# #
# NOTE: # NOTE:
# - For later; 'reboot --force --force' immediately kills the OS, like disabling ACPI on EL6 and hitting the # - For later; 'reboot --force --force' immediately kills the OS, like disabling ACPI on EL6 and hitting the
@ -1305,41 +1307,6 @@ sub handle_special_cases
}}); }});
return(0); return(0);
my $host_type = $anvil->Get->host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }});
if ($host_type ne "striker")
{
### TODO: Test that this is fixed. The bug is now ERRATA
# RHBZ #1961562 - https://bugzilla.redhat.com/show_bug.cgi?id=1961562#c16
# We're a node or DR host. We need to touch this file.
my $work_around_file = "/etc/qemu/firmware/50-edk2-ovmf-cc.json";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { work_around_file => $work_around_file }});
if (not -e $work_around_file)
{
$anvil->Storage->write_file({
debug => 2,
file => $work_around_file,
body => "",
overwrite => 0,
backup => 0,
mode => "0644",
user => "root",
group => "root",
});
}
# Make sure DRBD compiled after a kernel upgrade.
$anvil->DRBD->_initialize_kmod({debug => 2});
}
if ($host_type eq "striker")
{
}
return(0);
} }
# Configure the local database, if needed. # Configure the local database, if needed.

@ -30,6 +30,8 @@
# TODO: # TODO:
# - If two Strikers have the same file name, but different sizes, we get into a yo-yo of updating the two # - If two Strikers have the same file name, but different sizes, we get into a yo-yo of updating the two
# sides. If this happens, we need to rsync the larger one over the smaller one. # sides. If this happens, we need to rsync the larger one over the smaller one.
#
# - Create a ".done.<file_name>" when the upload completes so that we know it's time to add it to the database.
# #
# NOTE: # NOTE:
# - remove unsyncs, add syncs. # - remove unsyncs, add syncs.

Loading…
Cancel
Save