* Fixed a bug in Database->get_anvils() that was clearing the manifests hash.

* got anvil-join-anvil working up to the start of configuring pacemaker.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 1691674850
commit aa2fdfb609
  1. 4
      Anvil/Tools/Database.pm
  2. 1
      share/words.xml
  3. 98
      tools/anvil-join-anvil

@ -1547,9 +1547,9 @@ sub get_anvils
include_deleted => $include_deleted, include_deleted => $include_deleted,
}}); }});
if (exists $anvil->data->{manifests}) if (exists $anvil->data->{anvils})
{ {
delete $anvil->data->{manifests}; delete $anvil->data->{anvils};
} }
my $query = " my $query = "

@ -331,6 +331,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0089">Adding NTP (network time protocol) servers, if needed.</key> <key name="job_0089">Adding NTP (network time protocol) servers, if needed.</key>
<key name="job_0090">Adding the NTP server: [#!variable!server!#].</key> <key name="job_0090">Adding the NTP server: [#!variable!server!#].</key>
<key name="job_0091">Restarting the daemon: [#!variable!daemon!#].</key> <key name="job_0091">Restarting the daemon: [#!variable!daemon!#].</key>
<key name="job_0092"><![CDATA[[ Error ] - The Job: [#!variabe!job-uuid!#] appears to have passed malformed data. The raw data was: [#!variable!raw!#]. Expected 'as_machine=<host_type>,manifest_uuid=<manifest_uuid>,anvil_uuid=<anvil_uuid>'. Either the parse failed, or the data was somehow invalid.]]></key>
<!-- Log entries --> <!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key> <key name="log_0001">Starting: [#!variable!program!#].</key>

@ -8,6 +8,7 @@
# 2 = Failed to load/parse the manifest. # 2 = Failed to load/parse the manifest.
# 3 = Failed to change the host name. # 3 = Failed to change the host name.
# 4 = Failed to reconnect to any database after the network was reconfigured # 4 = Failed to reconnect to any database after the network was reconfigured
# 5 = Problem parsing job data or loading manifest or anvil data using job data.
# #
# TODO: # TODO:
# #
@ -15,6 +16,7 @@
use strict; use strict;
use warnings; use warnings;
use Anvil::Tools; use Anvil::Tools;
use Data::Dumper;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0]; my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0]; my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@ -42,16 +44,13 @@ if (not $anvil->data->{sys}{database}{connections})
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try # No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try
# again after we exit. # again after we exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0129"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0129"});
sleep 10; sleep 2;
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# Get the job details # Get the job details
load_job($anvil); load_job($anvil);
# Load in the manifest
load_manifest($anvil);
# Check if we need to change any IPs or our hostname. # Check if we need to change any IPs or our hostname.
check_local_network($anvil); check_local_network($anvil);
@ -74,14 +73,27 @@ sub configure_pacemaker
### TODO: Move these to variables in the 'sys' hash ### TODO: Move these to variables in the 'sys' hash
my $anvil_name = $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{name}; my $anvil_name = $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{name};
my $anvil_uuid = $anvil->data->{sys}{anvil_uuid};
my $host_name = $anvil->data->{sys}{host_name}; my $host_name = $anvil->data->{sys}{host_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:machine' => $machine, 's1:machine' => $machine,
's1:anvil_name' => $anvil_name, 's1:anvil_name' => $anvil_name,
's3:host_name' => $host_name, 's3:host_name' => $host_name,
's4:manifest_uuid' => $manifest_uuid,
's5:anvil_uuid' => $anvil_uuid,
}}); }});
print Dumper $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed};
print "=============================================\n";
print Dumper $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid};
print "=============================================\n";
=cut =cut
echo Initial1 | passwd hacluster --stdin
systemctl start pcsd.service
systemctl enable pcsd.service
systemctl disable libvirtd.service
systemctl stop libvirtd.service
909; xxx::upses::el8-ups01::uuid: [7ebecdda-782d-4624-841d-98d912ed3d50] 909; xxx::upses::el8-ups01::uuid: [7ebecdda-782d-4624-841d-98d912ed3d50]
909; xxx::upses::el8-ups02::uuid: [7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f] 909; xxx::upses::el8-ups02::uuid: [7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f]
918; xxx::fences::an-nas02::uuid: [4117a862-f58f-4676-991a-9ca257a3c612] 918; xxx::fences::an-nas02::uuid: [4117a862-f58f-4676-991a-9ca257a3c612]
@ -155,7 +167,7 @@ sub check_local_network
current_host_name => $now_host_name, current_host_name => $now_host_name,
}}); }});
update_progress($anvil, 0, "job_0063,!!host_name!".$new_host_name."!!,!!current_host_name!".$now_host_name."!!"); update_progress($anvil, 0, "job_0063,!!host_name!".$new_host_name."!!,!!current_host_name!".$now_host_name."!!");
sleep 10; sleep 2;
$anvil->nice_exit({exit_code => 3}); $anvil->nice_exit({exit_code => 3});
} }
} }
@ -270,8 +282,8 @@ sub check_local_network
if (($current_ip ne $ip) or ($current_subnet ne $subnet)) if (($current_ip ne $ip) or ($current_subnet ne $subnet))
{ {
# IP / subnet changed. # IP / subnet changed.
print "IP: .... [".$current_ip."] -> [".$ip."]\n"; #print "IP: .... [".$current_ip."] -> [".$ip."]\n";
print "Subnet: [".$current_subnet."] -> [".$subnet."]\n"; #print "Subnet: [".$current_subnet."] -> [".$subnet."]\n";
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
@ -279,7 +291,7 @@ sub check_local_network
# gateway? # gateway?
if ($current_gateway ne $gateway) if ($current_gateway ne $gateway)
{ {
print "Gateway: [".$current_gateway."] -> [".$gateway."]\n"; #print "Gateway: [".$current_gateway."] -> [".$gateway."]\n";
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
@ -289,14 +301,14 @@ sub check_local_network
{ {
if ($cleaned_dns ne $cleaned_current_dns) if ($cleaned_dns ne $cleaned_current_dns)
{ {
print "DNS: ... [".$cleaned_current_dns."] -> [".$cleaned_dns."]\n"; #print "DNS: ... [".$cleaned_current_dns."] -> [".$cleaned_dns."]\n";
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
elsif (($in_iface eq $default_gateway_interface) && (not $anvil->data->{network}{'local'}{interface}{$in_iface}{default_gateway})) elsif (($in_iface eq $default_gateway_interface) && (not $anvil->data->{network}{'local'}{interface}{$in_iface}{default_gateway}))
{ {
# This isn't the default gateway yet, but we'll make it so. # This isn't the default gateway yet, but we'll make it so.
print "Will set as default gateway\n"; #print "Will set as default gateway\n";
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
@ -819,7 +831,6 @@ sub check_local_network
# Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts # Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts
$anvil->System->check_ssh_keys({debug => 2}); $anvil->System->check_ssh_keys({debug => 2});
# Setup IPMI, if needed. # Setup IPMI, if needed.
### TODO: Do this when on real hardware ### TODO: Do this when on real hardware
@ -845,23 +856,54 @@ sub load_job
update_progress($anvil, ($anvil->data->{job}{progress} += 1), "job_0074,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!"); update_progress($anvil, ($anvil->data->{job}{progress} += 1), "job_0074,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0074", variables => { 'job-uuid' => $anvil->data->{switches}{'job-uuid'} }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0074", variables => { 'job-uuid' => $anvil->data->{switches}{'job-uuid'} }});
my ($machine, $manifest_uuid, $node1_host_uuid, $node2_host_uuid, $dr1_host_uuid) = ($anvil->data->{jobs}{job_data} =~ /as_machine=(.*?),manifest_uuid=(.*?),node1_host_uuid=(.*?),node2_host_uuid=(.*?),dr1_host_uuid=(.*?)$/); my ($machine, $manifest_uuid, $anvil_uuid) = ($anvil->data->{jobs}{job_data} =~ /as_machine=(.*?),manifest_uuid=(.*?),anvil_uuid=(.*?)$/);
$machine = "" if not defined $machine;
$manifest_uuid = "" if not defined $manifest_uuid;
$anvil_uuid = "" if not defined $anvil_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
machine => $machine, machine => $machine,
manifest_uuid => $manifest_uuid, manifest_uuid => $manifest_uuid,
node1_host_uuid => $node1_host_uuid, anvil_uuid => $anvil_uuid,
node2_host_uuid => $node2_host_uuid,
dr1_host_uuid => $dr1_host_uuid,
}}); }});
$anvil->data->{sys}{machine} = $machine; if ((not $machine) or
$anvil->data->{sys}{manifest_uuid} = $manifest_uuid; (not $manifest_uuid) or
$anvil->data->{sys}{node1_host_uuid} = $node1_host_uuid; (not $anvil_uuid))
$anvil->data->{sys}{node2_host_uuid} = $node2_host_uuid; {
$anvil->data->{sys}{node1_host_uuid} = $node1_host_uuid; # Terminate the job entirely, it's likely an unrecoverable problem.
update_progress($anvil, 100, "job_0092,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!,!!raw!".$anvil->data->{jobs}{job_data}."!!");
sleep 2;
$anvil->nice_exit({exit_code => 5});
}
$anvil->data->{sys}{machine} = $machine;
$anvil->data->{sys}{manifest_uuid} = $manifest_uuid;
$anvil->data->{sys}{anvil_uuid} = $anvil_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::machine" => $anvil->data->{sys}{machine}, "sys::machine" => $anvil->data->{sys}{machine},
"sys::manifest_uuid" => $anvil->data->{sys}{manifest_uuid}, "sys::manifest_uuid" => $anvil->data->{sys}{manifest_uuid},
"sys::anvil_uuid" => $anvil->data->{sys}{anvil_uuid},
}});
# Load in the manifest
load_manifest($anvil);
$anvil->Database->get_anvils();
# Load the manifest and anvil data.
if ((not exists $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}) or (not exists $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}))
{
# Terminate the job entirely, it's likely an unrecoverable problem.
update_progress($anvil, 100, "job_0092,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!,!!raw!".$anvil->data->{jobs}{job_data}."!!");
sleep 2;
$anvil->nice_exit({exit_code => 5});
}
# Load the anvil
$anvil->data->{sys}{node1_host_uuid} = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid};
$anvil->data->{sys}{node2_host_uuid} = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node2_host_uuid};
$anvil->data->{sys}{dr1_host_uuid} = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_dr1_host_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::node1_host_uuid" => $anvil->data->{sys}{node1_host_uuid}, "sys::node1_host_uuid" => $anvil->data->{sys}{node1_host_uuid},
"sys::node2_host_uuid" => $anvil->data->{sys}{node2_host_uuid}, "sys::node2_host_uuid" => $anvil->data->{sys}{node2_host_uuid},
"sys::dr1_host_uuid" => $anvil->data->{sys}{dr1_host_uuid}, "sys::dr1_host_uuid" => $anvil->data->{sys}{dr1_host_uuid},
@ -888,10 +930,10 @@ sub load_manifest
if ($problem) if ($problem)
{ {
# Report a problem and send the user back to the manifests page. # Something went wrong
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "warning_0046"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "warning_0046", variables => { uuid => $anvil->data->{sys}{manifest_uuid} }});
update_progress($anvil, 0, "job_0076"); update_progress($anvil, 0, "job_0076");
sleep 10; sleep 2;
$anvil->nice_exit({exit_code => 2}); $anvil->nice_exit({exit_code => 2});
} }

Loading…
Cancel
Save