* Updated anvil-daemon (and Database->insert_or_update_jobs) to now recognize jobs with the job_status of 'scancore_startup' to run only when ScanCore starts.

* Finished initial Striker setup in tools/striker-auto-initialize-all. Started working on peering.
* Cleaned up the handling of converting UIDs to user names in Remote->add_target_to_known_hosts() and ->_call_ssh_keyscan().
* Did a bunch of white-space/alignment cleanup.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 0fb191c00f
commit 15fd0e5ce8
  1. 1
      Anvil/Tools.pm
  2. 74
      Anvil/Tools/Database.pm
  3. 16
      Anvil/Tools/Remote.pm
  4. 7
      share/words.xml
  5. 33
      tools/anvil-daemon
  6. 216
      tools/striker-auto-initialize-all
  7. 26
      tools/striker-auto-initialize-all.example

@ -1189,6 +1189,7 @@ sub _set_paths
stonith_admin => "/usr/sbin/stonith_admin", stonith_admin => "/usr/sbin/stonith_admin",
storcli64 => "/opt/MegaRAID/storcli/storcli64", storcli64 => "/opt/MegaRAID/storcli/storcli64",
strings => "/usr/bin/strings", strings => "/usr/bin/strings",
'striker-auto-initialize-all' => "/usr/sbin/striker-auto-initialize-all",
'striker-get-peer-data' => "/usr/sbin/striker-get-peer-data", 'striker-get-peer-data' => "/usr/sbin/striker-get-peer-data",
'striker-initialize-host' => "/usr/sbin/striker-initialize-host", 'striker-initialize-host' => "/usr/sbin/striker-initialize-host",
'striker-manage-install-target' => "/usr/sbin/striker-manage-install-target", 'striker-manage-install-target' => "/usr/sbin/striker-manage-install-target",

@ -3208,33 +3208,33 @@ WHERE
my $job_status = $results->[0]->[10]; my $job_status = $results->[0]->[10];
my $modified_date = $results->[0]->[11]; my $modified_date = $results->[0]->[11];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
job_host_uuid => $job_host_uuid, job_host_uuid => $job_host_uuid,
job_command => $job_command, job_command => $job_command,
job_data => $job_data, job_data => $job_data,
job_picked_up_by => $job_picked_up_by, job_picked_up_by => $job_picked_up_by,
job_picked_up_at => $job_picked_up_at, job_picked_up_at => $job_picked_up_at,
job_updated => $job_updated, job_updated => $job_updated,
job_name => $job_name, job_name => $job_name,
job_progress => $job_progress, job_progress => $job_progress,
job_title => $job_title, job_title => $job_title,
job_description => $job_description, job_description => $job_description,
job_status => $job_status, job_status => $job_status,
modified_date => $modified_date, modified_date => $modified_date,
}}); }});
$return = { $return = {
job_host_uuid => $job_host_uuid, job_host_uuid => $job_host_uuid,
job_command => $job_command, job_command => $job_command,
job_data => $job_data, job_data => $job_data,
job_picked_up_by => $job_picked_up_by, job_picked_up_by => $job_picked_up_by,
job_picked_up_at => $job_picked_up_at, job_picked_up_at => $job_picked_up_at,
job_updated => $job_updated, job_updated => $job_updated,
job_name => $job_name, job_name => $job_name,
job_progress => $job_progress, job_progress => $job_progress,
job_title => $job_title, job_title => $job_title,
job_description => $job_description, job_description => $job_description,
job_status => $job_status, job_status => $job_status,
modified_date => $modified_date, modified_date => $modified_date,
}; };
return($return); return($return);
@ -3343,18 +3343,18 @@ WHERE
} }
push @{$return}, { push @{$return}, {
job_uuid => $job_uuid, job_uuid => $job_uuid,
job_command => $job_command, job_command => $job_command,
job_data => $job_data, job_data => $job_data,
job_picked_up_by => $job_picked_up_by, job_picked_up_by => $job_picked_up_by,
job_picked_up_at => $job_picked_up_at, job_picked_up_at => $job_picked_up_at,
job_updated => $job_updated, job_updated => $job_updated,
job_name => $job_name, job_name => $job_name,
job_progress => $job_progress, job_progress => $job_progress,
job_title => $job_title, job_title => $job_title,
job_description => $job_description, job_description => $job_description,
job_status => $job_status, job_status => $job_status,
modified_date => $modified_date, modified_date => $modified_date,
}; };
} }
@ -7481,6 +7481,8 @@ Variables can not be passed to this title key.
* This is not required when C<< update_progress_only >> is set * This is not required when C<< update_progress_only >> is set
B<< Note >>: This can be set to the special C<< scancore_startup >>. When the job status is set to this value, the job will only run when ScanCore next starts up (generally after a reboot).
=head3 job_uuid (optional) =head3 job_uuid (optional)
This is the C<< job_uuid >> to update. If it is not specified but the C<< job_name >> is, a check will be made to see if an entry already exists. If so, that row will be UPDATEd. If not, a random UUID will be generated and a new entry will be INSERTed. This is the C<< job_uuid >> to update. If it is not specified but the C<< job_name >> is, a check will be made to see if an entry already exists. If so, that row will be UPDATEd. If not, a random UUID will be generated and a new entry will be INSERTed.

@ -172,10 +172,16 @@ sub add_target_to_known_hosts
{ {
# Failed to add. :( # Failed to add. :(
my $say_user = $user;
if (($say_user =~ /^\d+$/) && (getpwuid($user)))
{
$say_user = getpwuid($user);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { say_user => $say_user }});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0009", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0009", variables => {
target => $target, target => $target,
port => $port, port => $port,
user => getpwuid($user) ? getpwuid($user) : $user, user => $say_user,
}}); }});
return(1); return(1);
} }
@ -1020,10 +1026,16 @@ sub _call_ssh_keyscan
}}); }});
# Log what we're doing # Log what we're doing
my $say_user = $user;
if (($say_user =~ /^\d+$/) && (getpwuid($user)))
{
$say_user = getpwuid($user);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { say_user => $say_user }});
}
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0159", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0159", variables => {
target => $target, target => $target,
port => $port, port => $port,
user => getpwuid($user) ? getpwuid($user) : $user, user => $say_user,
}}); }});
# Redirect STDERR to STDOUT and grep off the comments. # Redirect STDERR to STDOUT and grep off the comments.

@ -681,6 +681,12 @@ It should be provisioned in the next minute or two.</key>
<key name="job_0222">Preparing to delete the server: [#!variable!server_name!#].</key> <key name="job_0222">Preparing to delete the server: [#!variable!server_name!#].</key>
<key name="job_0223">Using virsh to destroy (force off) the server: [#!variable!server_name!#], if it is still running.</key> <key name="job_0223">Using virsh to destroy (force off) the server: [#!variable!server_name!#], if it is still running.</key>
<key name="job_0224">Enabled the HA repository for CentOS Stream.</key> <key name="job_0224">Enabled the HA repository for CentOS Stream.</key>
<key name="job_0225">Initialize Stage-1 installed systems into a full Anvil!.</key>
<key name="job_0226">This program is designed the automation of turning a set of stage-1 (bare OS + anvil-repo) systems and turn them into a fully functioning Anvil! system.</key>
<key name="job_0227">We need to setup pairing with Striker: [#!variable!number!#]. We will wait for it to come up. Be sure that you're run 'striker-auto-initialize-all' on it.</key>
<key name="job_0228">Successfully connected to Striker: [#!variable!number!#] using the IP: [#!variable!ip!#]!</key>
<key name="job_0229">No connection to Striker: [#!variable!number!#] via the IP: [#!variable!ip!#].</key>
<key name="job_0230">Failed to connect Striker: [#!variable!number!#] over any IPs. Sleeping a bit and then trying again.</key>
<!-- Log entries --> <!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key> <key name="log_0001">Starting: [#!variable!program!#].</key>
@ -1367,6 +1373,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0590">Wiping the metadata from the DRBD resource: [#!variable!resource!#].</key> <key name="log_0590">Wiping the metadata from the DRBD resource: [#!variable!resource!#].</key>
<key name="log_0591">Wiping any file system signatures and then deleting the logical volume: [#!variable!device_path!#].</key> <key name="log_0591">Wiping any file system signatures and then deleting the logical volume: [#!variable!device_path!#].</key>
<key name="log_0592">The resource name: [#!variable!resource_name!#] was found, returning the first TCP port and minor number.</key> <key name="log_0592">The resource name: [#!variable!resource_name!#] was found, returning the first TCP port and minor number.</key>
<key name="log_0593">The job: [#!variable!command!#] with UUID: [#!variable!job_uuid!#] is a start-time job, not running it now.</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

@ -717,9 +717,9 @@ FROM
WHERE WHERE
variable_source_table = 'hosts' variable_source_table = 'hosts'
AND AND
variable_source_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)." variable_source_uuid = ".$anvil->Database->quote($anvil->Get->host_uuid)."
AND AND
variable_name = 'reboot::needed' variable_name = 'reboot::needed'
;"; ;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
@ -774,6 +774,9 @@ AND
} }
} }
# Now look for jobs that have a job status of 'scancore_startup'
run_jobs($anvil, 1);
# Check the firewall needs to be updated. # Check the firewall needs to be updated.
check_firewall($anvil); check_firewall($anvil);
@ -856,7 +859,7 @@ sub keep_running
} }
# Run any pending jobs by calling 'anvil-jobs' with the 'job_uuid' as a background process. # Run any pending jobs by calling 'anvil-jobs' with the 'job_uuid' as a background process.
run_jobs($anvil) if not $anvil->data->{sys}{mapping_network}; run_jobs($anvil, 0) if not $anvil->data->{sys}{mapping_network};
return(0); return(0);
} }
@ -866,7 +869,8 @@ sub keep_running
# invoked to handle it. # invoked to handle it.
sub run_jobs sub run_jobs
{ {
my ($anvil) = @_; my ($anvil, $startup) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { startup => $startup }});
# This will be set to 1 if any jobs are not complete, preventing a restart of the daemon if it's # This will be set to 1 if any jobs are not complete, preventing a restart of the daemon if it's
# changed on disk. # changed on disk.
@ -876,11 +880,13 @@ sub run_jobs
my $jobs_file = "{\"jobs\":[\n"; my $jobs_file = "{\"jobs\":[\n";
# Get a list of pending or incomplete jobs. # Get a list of pending or incomplete jobs.
my $return = $anvil->Database->get_jobs({debug => 3, ended_within => 300}); my $ended_within = $startup ? 1 : 300;
my $count = @{$return}; my $return = $anvil->Database->get_jobs({debug => 3, ended_within => $ended_within});
my $count = @{$return};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
'return' => $return, ended_within => $ended_within,
count => $count, 'return' => $return,
count => $count,
}}); }});
foreach my $hash_ref (@{$return}) foreach my $hash_ref (@{$return})
{ {
@ -1023,6 +1029,17 @@ sub run_jobs
# If the job is done, move on. # If the job is done, move on.
next if $job_progress eq "100"; next if $job_progress eq "100";
# If 'startup' is set, we only care if 'job_status' is 'scancore_startup'
if ((not $startup) && ($say_status eq "scancore_startup"))
{
# Skip this, it will run next time anvil-daemon restarts.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0593", variables => {
command => $job_command,
job_uuid => $job_uuid,
}});
next;
}
# If the job is not running, start it. # If the job is not running, start it.
if ((not $job_picked_up_by) && ($job_progress ne "100") && (not $anvil->data->{switches}{'no-start'})) if ((not $job_picked_up_by) && ($job_progress ne "100") && (not $anvil->data->{switches}{'no-start'}))
{ {

@ -23,12 +23,6 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
=cut =cut
Striker initialization; Striker initialization;
anvil=# SELECT * FROM jobs WHERE job_uuid = '158e8384-eac7-4289-8f70-bc43eaf8b017';
job_uuid | job_host_uuid | job_command | job_data | job_picked_up_by | job_picked_up_at | job_updated | job_name | job_progress | job_title | job_description | job_status | modified_date
--------------------------------------+--------------------------------------+--------------------------------+--------------------+------------------+------------------+-------------+--------------------+--------------+-----------+-----------------+------------+-------------------------------
158e8384-eac7-4289-8f70-bc43eaf8b017 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | /usr/sbin/anvil-configure-host | form::config_step2 | 0 | 0 | 1613525509 | configure::network | 0 | job_0001 | job_0002 | | 2021-02-16 20:31:49.108908-05
# At this point, the Striker should be coming up at the IP. Once both/all Strikers are up, update their anvil.conf to add each other's UUID database entry. # At this point, the Striker should be coming up at the IP. Once both/all Strikers are up, update their anvil.conf to add each other's UUID database entry.
# FROM ONE STRIKER; # FROM ONE STRIKER;
job_uuid | job_host_uuid | job_command | job_data | job_picked_up_by | job_picked_up_at | job_updated | job_name | job_progress | job_title | job_description | job_status | modified_date job_uuid | job_host_uuid | job_command | job_data | job_picked_up_by | job_picked_up_at | job_updated | job_name | job_progress | job_title | job_description | job_status | modified_date
@ -77,6 +71,8 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, priority => "err", key => "error_0003"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, priority => "err", key => "error_0003"});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
$anvil->data->{switches}{config} = "";
$anvil->data->{switches}{'job-uuid'} = "";
$anvil->Get->switches; $anvil->Get->switches;
# Read in the config file # Read in the config file
@ -99,26 +95,26 @@ if ((not exists $anvil->data->{base}{prefix}) or ($anvil->data->{base}{prefix} e
# Find myself # Find myself
find_myself($anvil); find_myself($anvil);
if (not $anvil->data->{striker}{i_am}) if (not $anvil->data->{i_am}{striker})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0242", variables => { file => $anvil->data->{switches}{config} }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0242", variables => { file => $anvil->data->{switches}{config} }});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
# If I am not configured, configure myself now. # If I am not configured, configure myself now.
#my $configured = $anvil->System->check_if_configured; my $configured = $anvil->System->check_if_configured;
my $configured = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }});
if ($configured) if ($configured)
{ {
# If I am not Striker 1, I am done. # If I am not Striker 1, I am done.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "striker::i_am" => $anvil->data->{striker}{i_am} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "i_am::striker" => $anvil->data->{i_am}{striker} }});
if ($anvil->data->{striker}{i_am} ne "1") if ($anvil->data->{i_am}{striker} ne "1")
{ {
# We're done. # We're done.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0221", variables => { striker => $anvil->data->{striker}{i_am} }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "message_0221", variables => { striker => $anvil->data->{i_am}{striker} }});
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }
striker_stage2($anvil);
} }
else else
{ {
@ -138,6 +134,127 @@ $anvil->nice_exit({exit_code => 0});
# Functions # # Functions #
############################################################################################################# #############################################################################################################
# This does the rest of the setup.
sub striker_stage2
{
my ($anvil) = @_;
# Merge my peer Striker.
merge_peer_striker($anvil);
return(0);
}
# Merge my peer Striker.
sub merge_peer_striker
{
my ($anvil) = @_;
# For each peer, see if we're already connected to it.
foreach my $striker_number (sort {$a cmp $b} keys %{$anvil->data->{striker}})
{
next if $striker_number !~ /^\d+$/;
next if $striker_number == $anvil->data->{i_am}{striker};
next if not exists $anvil->data->{striker}{$striker_number}{network};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { striker_number => $striker_number }});
# Use the MAC address(es) to look for a host UUID. If we don't find one, we need to peer it.
my $peer_host_uuid = 0;
my $peer_ips = [];
foreach my $network (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }});
foreach my $network_number (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}{$network}})
{
my $ip = $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip};
push @{$peer_ips}, $ip;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
network_number => $network_number,
ip => $ip,
}});
foreach my $link_number (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}})
{
next if $peer_host_uuid;
my $mac_address = lc($anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{$link_number}{mac});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
link_number => $link_number,
mac_address => $mac_address,
}});
my $query = "
SELECT
network_interface_host_uuid
FROM
network_interfaces
WHERE
network_interface_operational != 'DELETED'
AND
network_interface_mac_address = ".$anvil->Database->quote($mac_address)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
if ($count)
{
$peer_host_uuid = $results->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { peer_host_uuid => $peer_host_uuid }});
}
}
}
}
if (not $peer_host_uuid)
{
### Add the peer.
# First, wait for access.
my $waiting = 1;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0227", variables => { number => $striker_number }});
while ($waiting)
{
foreach my $ip (@{$peer_ips})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ip => $ip }});
my $access = $anvil->Remote->test_access({
target => $ip,
password => $anvil->data->{base}{password}{desired},
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { access => $access }});
if ($access)
{
# Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0228", variables => {
number => $striker_number,
ip => $ip,
}});
exit(0);
}
else
{
# No access
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0229", variables => {
number => $striker_number,
ip => $ip,
}});
}
}
if ($waiting)
{
# Wait 30 seconds and try again
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0230", variables => { number => $striker_number }});
sleep 30;
}
}
}
}
return(0);
}
# This preps and requests the initial configuration job. # This preps and requests the initial configuration job.
sub striker_stage1 sub striker_stage1
{ {
@ -205,7 +322,7 @@ sub striker_stage1
} }
} }
my $striker_number = $anvil->data->{striker}{i_am}; my $striker_number = $anvil->data->{i_am}{striker};
my $organization_name = $anvil->data->{base}{organization_name}; my $organization_name = $anvil->data->{base}{organization_name};
my $prefix = $anvil->data->{base}{prefix}; my $prefix = $anvil->data->{base}{prefix};
my $domain = $anvil->data->{base}{domain}; my $domain = $anvil->data->{base}{domain};
@ -379,6 +496,36 @@ sub striker_stage1
} }
# Call anvil-configure-host now.
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
debug => 2,
job_host_uuid => $anvil->data->{cgi}{host_uuid}{value},
job_command => $anvil->data->{path}{exe}{'anvil-configure-host'},
job_data => "form::config_step2",
job_name => "configure::network",
job_title => "job_0001",
job_description => "job_0071",
job_progress => 0,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
# If we're striker 1, add a job to restart ourselves when ScanCore starts (after the reboot)
if ($striker_number eq "1")
{
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
debug => 2,
job_host_uuid => $anvil->data->{cgi}{host_uuid}{value},
job_command => $anvil->data->{path}{exe}{'striker-auto-initialize-all'}." --config ".$anvil->data->{switches}{config},
job_data => "",
job_name => "configure::auto_initialize",
job_title => "job_0225",
job_description => "job_0226",
job_status => "scancore_startup",
job_progress => 0,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
}
return(0); return(0);
} }
@ -393,14 +540,7 @@ sub find_myself
$anvil->Network->get_ips({debug => 3}); $anvil->Network->get_ips({debug => 3});
# print Dumper $anvil->data->{network}{$short_host_name}{interface}; $anvil->data->{i_am}{striker} = 0;
# foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$short_host_name}{interface}})
# {
# print "Interface: [".$interface."]\n";
# }
# die;
$anvil->data->{striker}{i_am} = 0;
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$short_host_name}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$short_host_name}{interface}})
{ {
my $ip_address = $anvil->data->{network}{$short_host_name}{interface}{$interface}{ip}; my $ip_address = $anvil->data->{network}{$short_host_name}{interface}{$interface}{ip};
@ -423,6 +563,7 @@ sub find_myself
foreach my $striker_number (sort {$a cmp $b} keys %{$anvil->data->{striker}}) foreach my $striker_number (sort {$a cmp $b} keys %{$anvil->data->{striker}})
{ {
next if $striker_number !~ /^\d+$/;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { striker_number => $striker_number }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { striker_number => $striker_number }});
foreach my $network (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}}) foreach my $network (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}})
{ {
@ -439,12 +580,12 @@ sub find_myself
mac_address => $mac_address, mac_address => $mac_address,
this_mac_address => $this_mac_address, this_mac_address => $this_mac_address,
}}); }});
if ((not $anvil->data->{striker}{i_am}) && ($this_mac_address eq $mac_address)) if ((not $anvil->data->{i_am}{striker}) && ($this_mac_address eq $mac_address))
{ {
# This is us. # This is us.
$anvil->data->{striker}{i_am} = $striker_number; $anvil->data->{i_am}{striker} = $striker_number;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "striker::i_am" => $anvil->data->{striker}{i_am} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "i_am::striker" => $anvil->data->{i_am}{striker} }});
return($anvil->data->{striker}{i_am}); return($anvil->data->{i_am}{striker});
} }
} }
} }
@ -452,7 +593,28 @@ sub find_myself
} }
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { i_am_striker => $anvil->data->{striker}{i_am} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { i_am_striker => $anvil->data->{i_am}{striker} }});
return($anvil->data->{striker}{i_am}); return($anvil->data->{i_am}{striker});
} }
# If this is being called as a job, this will allow the progress to be updated.
sub update_progress
{
my ($anvil, $progress, $message) = @_;
$progress = 95 if $progress > 100;
if (not $anvil->data->{switches}{'job-uuid'})
{
return(0);
}
$anvil->Job->update_progress({
debug => 3,
progress => $progress,
message => $message,
job_uuid => $anvil->data->{switches}{'job-uuid'},
});
return(0);
}

@ -32,20 +32,24 @@ base::password::desired = super secret password
############################################################################################################# #############################################################################################################
# Striker configurations # # Striker configurations #
############################################################################################################# #############################################################################################################
# Startup IP is used for peers to find us
striker::1::startup_ip = 192.168.122.145 ### NOTE: 'striker::1::' is the Striker that will merge the dashboards, initialize nodes / DR, create the
striker::1::network::ifn::1::ip = 192.168.122.11 ### install manifest (and fence devices / upses), and assemble the nodes. As such, 'striker::1::' is
### required!
striker::1::network::ifn::1::ip = 192.168.122.251
striker::1::network::ifn::1::subnet_mask = 255.255.255.0 striker::1::network::ifn::1::subnet_mask = 255.255.255.0
striker::1::network::ifn::1::link::1::mac = 52:54:00:ac:50:e4 striker::1::network::ifn::1::link::1::mac = 52:54:00:df:03:e
striker::1::network::ifn::1::link::2::mac = 52:54:00:45:6e:5d
striker::1::network::bcn::1::ip = 10.201.4.1 striker::1::network::bcn::1::ip = 10.201.4.1
striker::1::network::bcn::1::subnet_mask = 255.255.0.0 striker::1::network::bcn::1::subnet_mask = 255.255.0.0
striker::1::network::bcn::1::link::1::mac = 52:54:00:68:be:2e striker::1::network::bcn::1::link::1::mac = 52:54:00:d9:24:52
striker::1::network::bcn::1::link::2::mac = 52:54:00:aa:4d:e0
striker::2::startup_ip = 192.168.122.146 striker::2::network::ifn::1::ip = 192.168.122.252
striker::2::network::ifn::1::ip = 192.168.122.12
striker::2::network::ifn::1::subnet_mask = 255.255.255.0 striker::2::network::ifn::1::subnet_mask = 255.255.255.0
striker::2::network::ifn::1::link::1::mac = 52:54:00:c0:f2:7c striker::2::network::ifn::1::link::1::mac = 52:54:00:41:1f:7d
striker::2::network::bcn::1::ip = 192.168.122.12 striker::2::network::ifn::1::link::2::mac = 52:54:00:33:f7:de
striker::2::network::bcn::1::ip = 192.168.122.252
striker::2::network::bcn::1::subnet_mask = 255.255.255.0 striker::2::network::bcn::1::subnet_mask = 255.255.255.0
striker::2::network::bcn::1::link::1::mac = 52:54:00:8b:d6:82 striker::2::network::bcn::1::link::1::mac = 52:54:00:b8:34:a7
striker::2::network::bcn::1::link::2::mac = 52:54:00:30:f9:db

Loading…
Cancel
Save