@ -23,30 +23,6 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
=cut
=cut
Striker initialization;
Striker initialization;
# Figure out if we're striker '1' or '2' by matching found MAC addresses against configured MAC addresses.
# Striker 1 will, after configuring itself, reboot and wait for access to Striker 2. Then it will bond the two and begin configuring nodes (and DR, if defined)
data source | variable_name | variable_value | variable_default | variable_description | variable_section | variable_source_uuid | variable_source_table | modified_date
------------------------------------------+--------------------------------------------------+-------------------------+------------------+----------------------+------------------+--------------------------------------+-----------------------+-------------------------------
base::organization_name | form::config_step1::organization::value | Alteeve | | striker_0004 | config_step1 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:26:22.938934-05
base::prefix | form::config_step1::prefix::value | di | | striker_0006 | config_step1 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:26:22.938934-05
base::domain | form::config_step1::domain::value | digimer.ca | | striker_0008 | config_step1 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:26:22.938934-05
keys %{striker}{1}{network}{ifn} | form::config_step1::ifn_count::value | 1 | | striker_0012 | config_step1 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:26:22.938934-05
# Match MAC for Striker sequence | form::config_step1::sequence::value | 2 | | striker_0010 | config_step1 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:27:39.491016-05
<prefix>-striker0<sequence>.<domain> | form::config_step2::host_name::value | di-striker02.digimer.ca | | striker_0017 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
# Hard code to 'admin' | form::config_step2::striker_user::value | admin | | striker_0032 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
base::password::desired | form::config_step2::striker_password::value | super secret password | | striker_0034 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
base::dns | form::config_step2::dns::value | 8.8.8.8, 8.8.4.4 | | striker_0038 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
base::gateway | form::config_step2::gateway::value | 192.168.122.1 | | striker_0036 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:30:16.688974-05
base::interface | form::config_step2::gateway_interface::value | ifn1 | | | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:30:16.688974-05
striker::1::network::bcn::1::ip | form::config_step2::bcn1_ip::value | 10.201.4.2 | | striker_0024 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
striker::1::network::bcn::1::subnet_mask | form::config_step2::bcn1_subnet_mask::value | 255.255.0.0 | | striker_0025 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
striker::1::network::bcn::1::link::1::mac | form::config_step2::bcn1_link1_mac_to_set::value | 52:54:00:8b:d6:82 | | striker_0029 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
striker::1::network::ifn::1::subnet_mask | form::config_step2::ifn1_subnet_mask::value | 255.255.255.0 | | striker_0025 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
striker::1::network::ifn::1::link::1::mac | form::config_step2::ifn1_link1_mac_to_set::value | 52:54:00:c0:f2:7c | | striker_0029 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:29:59.317812-05
striker::1::network::ifn::1::ip | form::config_step2::ifn1_ip::value | 192.168.122.12 | | striker_0024 | config_step2 | a64c477b-b0a1-4985-9968-f4b46d75fb0c | hosts | 2021-02-16 20:30:16.688974-05
anvil=# SELECT * FROM jobs WHERE job_uuid = '158e8384-eac7-4289-8f70-bc43eaf8b017';
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
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
--------------------------------------+--------------------------------------+--------------------------------+--------------------+------------------+------------------+-------------+--------------------+--------------+-----------+-----------------+------------+-------------------------------
--------------------------------------+--------------------------------------+--------------------------------+--------------------+------------------+------------------+-------------+--------------------+--------------+-----------+-----------------+------------+-------------------------------
@ -114,8 +90,369 @@ if ((not $anvil->data->{switches}{config}) or (not -f $anvil->data->{switches}{c
# Load the config.
# Load the config.
$anvil->Storage->read_config({file => $anvil->data->{switches}{config}});
$anvil->Storage->read_config({file => $anvil->data->{switches}{config}});
print Dumper $anvil->data->{base};
# Check that 'prefix' is now set as a rough test that the file we read was useful.
print Dumper $anvil->data->{striker};
if ((not exists $anvil->data->{base}{prefix}) or ($anvil->data->{base}{prefix} eq ""))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0241", variables => { file => $anvil->data->{switches}{config} }});
$anvil->nice_exit({exit_code => 1});
}
# Find myself
find_myself($anvil);
if (not $anvil->data->{striker}{i_am})
{
$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});
}
# If I am not configured, configure myself now.
#my $configured = $anvil->System->check_if_configured;
my $configured = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }});
if ($configured)
{
# 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} }});
if ($anvil->data->{striker}{i_am} ne "1")
{
# 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->nice_exit({exit_code => 0});
}
}
else
{
# Do the initial setup of ourselves.
striker_stage1($anvil);
}
#print Dumper $anvil->data->{base};
#print Dumper $anvil->data->{striker};
$anvil->nice_exit({exit_code => 0});
$anvil->nice_exit({exit_code => 0});
#############################################################################################################
# Functions #
#############################################################################################################
# This preps and requests the initial configuration job.
sub striker_stage1
{
my ($anvil) = @_;
### TODO: Validate all steps up front before starting anything.
if ((not defined $anvil->data->{base}{organization_name}) or (not $anvil->data->{base}{organization_name}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => { variable => 'base::organization_name' }});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{base}{prefix}) or (not $anvil->data->{base}{prefix}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => { variable => 'base::prefix' }});
$anvil->nice_exit({exit_code => 1});
}
elsif (length($anvil->data->{base}{prefix}) > 5)
{
# Prefix is too long
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0244", variables => {
prefix => $anvil->data->{base}{prefix},
'length' => length($anvil->data->{base}{prefix}),
}});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{base}{domain}) or (not $anvil->data->{base}{domain}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => { variable => 'base::domain' }});
$anvil->nice_exit({exit_code => 1});
}
elsif (not $anvil->Validate->domain_name({name => $anvil->data->{base}{domain}}))
{
# Domain is not valid
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0117", variables => { name => $anvil->data->{base}{domain} }});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{base}{password}{desired}) or (not $anvil->data->{base}{password}{desired}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => { variable => 'base::password::desired' }});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{base}{dns}) or (not $anvil->data->{base}{dns}))
{
$anvil->data->{base}{dns} = "8.8.8.8,8.8.4.4";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "base::dns" => $anvil->data->{base}{dns} }});
}
else
{
# Make sure any/all DNS are valid.
foreach my $ip (split/,/, $anvil->data->{base}{dns})
{
if (not $anvil->Validate->ipv4({ip => $ip}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0245", variables => { ip => $ip }});
$anvil->nice_exit({exit_code => 1});
}
}
}
if ((defined $anvil->data->{base}{gateway}) && ($anvil->data->{base}{gateway}))
{
if (not $anvil->Validate->ipv4({ip => $anvil->data->{base}{gateway}}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0246", variables => { ip => $anvil->data->{base}{gateway} }});
$anvil->nice_exit({exit_code => 1});
}
}
my $striker_number = $anvil->data->{striker}{i_am};
my $organization_name = $anvil->data->{base}{organization_name};
my $prefix = $anvil->data->{base}{prefix};
my $domain = $anvil->data->{base}{domain};
my $ifn_count = keys %{$anvil->data->{striker}{$striker_number}{network}{ifn}};
my $host_name = $prefix."-striker0".$striker_number.".".$domain;
my $new_password = $anvil->data->{base}{password}{desired};
my $dns = $anvil->data->{base}{dns};
my $gateway = $anvil->data->{base}{gateway};
my $gateway_network = defined $anvil->data->{base}{gateway_network} ? $anvil->data->{base}{gateway_network} : "ifn1";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
striker_number => $striker_number,
organization_name => $organization_name,
prefix => $prefix,
domain => $domain,
ifn_count => $ifn_count,
host_name => $host_name,
new_password => $anvil->Log->is_secure($new_password),
dns => $dns,
gateway => $gateway,
gateway_network => $gateway_network,
}});
# Load the variables.
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::organization::value'}{variable_value} = $organization_name;
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::organization::value'}{variable_description} = "striker_0004";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::organization::value'}{variable_section} = "config_step1";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::prefix::value'}{variable_value} = $prefix;
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::prefix::value'}{variable_description} = "striker_0006";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::prefix::value'}{variable_section} = "config_step1";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::domain::value'}{variable_value} = $domain;
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::domain::value'}{variable_description} = "striker_0008";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::domain::value'}{variable_section} = "config_step1";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::ifn_count::value'}{variable_value} = $ifn_count;
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::ifn_count::value'}{variable_description} = "striker_0012";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::ifn_count::value'}{variable_section} = "config_step1";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::sequence::value'}{variable_value} = $striker_number;
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::sequence::value'}{variable_description} = "striker_0010";
$anvil->data->{striker}{stage1}{variables}{'form::config_step1::sequence::value'}{variable_section} = "config_step1";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::host_name::value'}{variable_value} = $host_name;
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::host_name::value'}{variable_description} = "striker_0017";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::host_name::value'}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_user::value'}{variable_value} = "admin";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_user::value'}{variable_description} = "striker_0032";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_user::value'}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_password::value'}{variable_value} = $new_password;
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_password::value'}{variable_description} = "striker_0034";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::striker_password::value'}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::dns::value'}{variable_value} = $dns;
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::dns::value'}{variable_description} = "striker_0038";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::dns::value'}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway::value'}{variable_value} = $gateway;
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway::value'}{variable_description} = "striker_0036";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway::value'}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway_interface::value'}{variable_value} = $gateway_network;
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway_interface::value'}{variable_description} = "";
$anvil->data->{striker}{stage1}{variables}{'form::config_step2::gateway_interface::value'}{variable_section} = "config_step2";
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}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_number => $network_number }});
if ((not defined $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip}) or (not $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::ip",
}});
$anvil->nice_exit({exit_code => 1});
}
elsif (not $anvil->Validate->ipv4({ip => $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip}}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0247", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::ip",
value => $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip},
}});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{subnet_mask}) or (not $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{subnet_mask}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::subnet_mask",
}});
$anvil->nice_exit({exit_code => 1});
}
elsif (not $anvil->Validate->ipv4({ip => $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{subnet_mask}}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0247", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::subnet_mask",
value => $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{subnet_mask},
}});
$anvil->nice_exit({exit_code => 1});
}
if ((not defined $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{1}{mac}) or (not $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{1}{mac}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::link::1::mac",
}});
$anvil->nice_exit({exit_code => 1});
}
my $ip_key = "form::config_step2::".$network.$network_number."_ip::value";
my $ip = $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{ip};
my $subnet_mask_key = "form::config_step2::".$network.$network_number."_subnet_mask::value";
my $subnet_mask = $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{subnet_mask};
my $link1_mac_key = "form::config_step2::".$network.$network_number."_link1_mac_to_set::value";
my $link1_mac = $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{1}{mac};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:ip_key' => $ip_key,
's2:ip' => $ip,
's3:subnet_mask_key' => $subnet_mask_key,
's4:subnet_mask' => $subnet_mask,
's4:link1_mac_key' => $link1_mac_key,
's5:link1_mac' => $link1_mac,
}});
$anvil->data->{striker}{stage1}{variables}{$ip_key}{variable_value} = $ip;
$anvil->data->{striker}{stage1}{variables}{$ip_key}{variable_description} = "striker_0024";
$anvil->data->{striker}{stage1}{variables}{$ip_key}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{$subnet_mask_key}{variable_value} = $subnet_mask;
$anvil->data->{striker}{stage1}{variables}{$subnet_mask_key}{variable_description} = "striker_0025";
$anvil->data->{striker}{stage1}{variables}{$subnet_mask_key}{variable_section} = "config_step2";
$anvil->data->{striker}{stage1}{variables}{$link1_mac_key}{variable_value} = $link1_mac;
$anvil->data->{striker}{stage1}{variables}{$link1_mac_key}{variable_description} = "striker_0029";
$anvil->data->{striker}{stage1}{variables}{$link1_mac_key}{variable_section} = "config_step2";
if (exists $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{2})
{
if ((not defined $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{2}{mac}) or (not $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{2}{mac}))
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "error_0243", variables => {
variable => "striker::${striker_number}::network::${network}::${network_number}::link::2::mac",
}});
$anvil->nice_exit({exit_code => 1});
}
my $link2_mac_key = "form::config_step2::".$network.$network_number."_link2_mac_to_set::value";
my $link2_mac = $anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}{2}{mac};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:link2_mac_key' => $link2_mac_key,
's2:link2_mac' => $link2_mac,
}});
$anvil->data->{striker}{stage1}{variables}{$link2_mac_key}{variable_value} = $link2_mac;
$anvil->data->{striker}{stage1}{variables}{$link2_mac_key}{variable_description} = "striker_0029";
$anvil->data->{striker}{stage1}{variables}{$link2_mac_key}{variable_section} = "config_step2";
}
}
}
# Now, for each variable, record it to the database.
foreach my $variable (sort {$a cmp $b} keys %{$anvil->data->{striker}{stage1}{variables}})
{
my $value = $anvil->data->{striker}{stage1}{variables}{$variable}{variable_value};
my $description = $anvil->data->{striker}{stage1}{variables}{$variable}{variable_description};
my $section = $anvil->data->{striker}{stage1}{variables}{$variable}{variable_section};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:variable' => $variable,
's2:value' => $value,
's3:description' => $description,
's4:section' => $section,
}});
my ($variable_uuid) = $anvil->Database->insert_or_update_variables({
variable_name => $variable,
variable_value => $value,
variable_default => "",
variable_description => $description,
variable_section => $section,
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { variable_uuid => $variable_uuid }});
}
return(0);
}
# This looks to see if we can map a 'striker::X::' to this machine.
sub find_myself
{
my ($anvil) = @_;
# Find my MAC addresses.
my $short_host_name = $anvil->Get->short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { short_host_name => $short_host_name }});
$anvil->Network->get_ips({debug => 3});
# print Dumper $anvil->data->{network}{$short_host_name}{interface};
# 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}})
{
my $ip_address = $anvil->data->{network}{$short_host_name}{interface}{$interface}{ip};
my $subnet_mask = $anvil->data->{network}{$short_host_name}{interface}{$interface}{subnet_mask};
my $mac_address = $anvil->data->{network}{$short_host_name}{interface}{$interface}{mac_address};
my $mtu = $anvil->data->{network}{$short_host_name}{interface}{$interface}{mtu};
my $default_gateway = $anvil->data->{network}{$short_host_name}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{network}{$short_host_name}{interface}{$interface}{gateway};
my $dns = $anvil->data->{network}{$short_host_name}{interface}{$interface}{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
interface => $interface,
ip_address => $ip_address,
subnet_mask => $subnet_mask,
mac_address => $mac_address,
mtu => $mtu,
default_gateway => $default_gateway,
gateway => $gateway,
dns => $dns,
}});
foreach my $striker_number (sort {$a cmp $b} keys %{$anvil->data->{striker}})
{
$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}})
{
$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}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_number => $network_number }});
foreach my $link_number (sort {$a cmp $b} keys %{$anvil->data->{striker}{$striker_number}{network}{$network}{$network_number}{'link'}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { link_number => $link_number }});
my $this_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 => {
mac_address => $mac_address,
this_mac_address => $this_mac_address,
}});
if ((not $anvil->data->{striker}{i_am}) && ($this_mac_address eq $mac_address))
{
# This is us.
$anvil->data->{striker}{i_am} = $striker_number;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "striker::i_am" => $anvil->data->{striker}{i_am} }});
return($anvil->data->{striker}{i_am});
}
}
}
}
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { i_am_striker => $anvil->data->{striker}{i_am} }});
return($anvil->data->{striker}{i_am});
}