* Updated Get->host_uuid to record the UUID to a cache file when run with root privs, but read from the cache when an unpriv user.

* Added a start-check to make sure 'home' could read the host UUID and exit if not.
* Removed network_interface_current_name / network_interface_requested_name from the network_interfaces DB table and used simply network_interface_name.
* Added caching to Storage->read_file().
* Now record form answers in the variables table as 'form::<form_name>::<variable>::value' and read the same when the form is first loaded.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 96670756ab
commit 1e7fe44c23
  1. 2
      AN/Tools.pm
  2. 211
      AN/Tools/Database.pm
  3. 44
      AN/Tools/Get.pm
  4. 57
      AN/Tools/Storage.pm
  5. 13
      AN/Tools/Template.pm
  6. 6
      AN/an-tools.xml
  7. 153
      cgi-bin/home
  8. 1
      cgi-bin/words.xml
  9. 2
      html/skins/alteeve/main.js
  10. 12
      scancore.sql
  11. 18
      tools/an-prep-database
  12. 16
      tools/scancore-update-states

@ -685,6 +685,8 @@ sub _set_paths
'striker.conf' => "/etc/striker/striker.conf", 'striker.conf' => "/etc/striker/striker.conf",
}, },
data => { data => {
group => "/etc/group",
host_uuid => "/etc/an/host.uuid",
passwd => "/etc/passwd", passwd => "/etc/passwd",
}, },
directories => { directories => {

@ -1460,10 +1460,6 @@ If this interface is part of a bond, this UUID will be the C<< bonds >> -> C<< b
If this interface is connected to a bridge, this is the C<< bridges >> -> C<< bridge_uuid >> of that bridge. If this interface is connected to a bridge, this is the C<< bridges >> -> C<< bridge_uuid >> of that bridge.
=head3 network_interface_current_name (required)
This is the current device name for this interface.
=head3 network_interface_duplex (optional) =head3 network_interface_duplex (optional)
This can be set to C<< full >>, C<< half >> or C<< unknown >>, with the later being the default. This can be set to C<< full >>, C<< half >> or C<< unknown >>, with the later being the default.
@ -1488,13 +1484,13 @@ This is the medium the interface uses. This is generally C<< copper >>, C<< fibe
This is the maximum transmit unit (MTU) that this interface supports, in bytes per second. This is usally C<< 1500 >>. This is the maximum transmit unit (MTU) that this interface supports, in bytes per second. This is usally C<< 1500 >>.
=head3 network_interface_operational (optional) =head3 network_interface_name (required)
This can be set to C<< up >>, C<< down >> or C<< unknown >>, with the later being the default. This indicates whether the interface is active or not. This is the current device name for this interface.
=head3 network_interface_requested_name (optional) =head3 network_interface_operational (optional)
This can be set to a different device name from what is currently assigned. If it is set, and if it differs from the current device name, it will be reconfigured the next time the network is updated. This can be set to C<< up >>, C<< down >> or C<< unknown >>, with the later being the default. This indicates whether the interface is active or not.
=head3 network_interface_speed (optional) =head3 network_interface_speed (optional)
@ -1512,35 +1508,33 @@ sub insert_or_update_network_interfaces
my $an = $self->parent; my $an = $self->parent;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0125", variables => { method => "Database->insert_or_update_network_interfaces()" }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0125", variables => { method => "Database->insert_or_update_network_interfaces()" }});
my $id = defined $parameter->{id} ? $parameter->{id} : ""; my $id = defined $parameter->{id} ? $parameter->{id} : "";
my $network_interface_bond_uuid = defined $parameter->{network_interface_bond_uuid} ? $parameter->{network_interface_bond_uuid} : "--"; my $network_interface_bond_uuid = defined $parameter->{network_interface_bond_uuid} ? $parameter->{network_interface_bond_uuid} : "--";
my $network_interface_bridge_uuid = defined $parameter->{network_interface_bridge_uuid} ? $parameter->{network_interface_bridge_uuid} : "--"; my $network_interface_bridge_uuid = defined $parameter->{network_interface_bridge_uuid} ? $parameter->{network_interface_bridge_uuid} : "--";
my $network_interface_current_name = defined $parameter->{network_interface_current_name} ? $parameter->{network_interface_current_name} : "--"; my $network_interface_duplex = defined $parameter->{network_interface_duplex} ? $parameter->{network_interface_duplex} : "--";
my $network_interface_duplex = defined $parameter->{network_interface_duplex} ? $parameter->{network_interface_duplex} : "--"; my $network_interface_host_uuid = defined $parameter->{network_interface_host_uuid} ? $parameter->{network_interface_host_uuid} : $an->Get->host_uuid;
my $network_interface_host_uuid = defined $parameter->{network_interface_host_uuid} ? $parameter->{network_interface_host_uuid} : $an->Get->host_uuid; my $network_interface_link_state = defined $parameter->{network_interface_link_state} ? $parameter->{network_interface_link_state} : "--";
my $network_interface_link_state = defined $parameter->{network_interface_link_state} ? $parameter->{network_interface_link_state} : "--"; my $network_interface_operational = defined $parameter->{network_interface_operational} ? $parameter->{network_interface_operational} : "--";
my $network_interface_operational = defined $parameter->{network_interface_operational} ? $parameter->{network_interface_operational} : "--"; my $network_interface_mac_address = defined $parameter->{network_interface_mac_address} ? $parameter->{network_interface_mac_address} : "--";
my $network_interface_mac_address = defined $parameter->{network_interface_mac_address} ? $parameter->{network_interface_mac_address} : "--"; my $network_interface_medium = defined $parameter->{network_interface_medium} ? $parameter->{network_interface_medium} : "--";
my $network_interface_medium = defined $parameter->{network_interface_medium} ? $parameter->{network_interface_medium} : "--"; my $network_interface_mtu = defined $parameter->{network_interface_mtu} ? $parameter->{network_interface_mtu} : "--";
my $network_interface_mtu = defined $parameter->{network_interface_mtu} ? $parameter->{network_interface_mtu} : "--"; my $network_interface_name = defined $parameter->{network_interface_name} ? $parameter->{network_interface_name} : "--";
my $network_interface_requested_name = defined $parameter->{network_interface_requested_name} ? $parameter->{network_interface_requested_name} : "--"; my $network_interface_speed = defined $parameter->{network_interface_speed} ? $parameter->{network_interface_speed} : "--";
my $network_interface_speed = defined $parameter->{network_interface_speed} ? $parameter->{network_interface_speed} : "--"; my $network_interface_uuid = defined $parameter->{network_interface_uuid} ? $parameter->{interface_uuid} : "";
my $network_interface_uuid = defined $parameter->{network_interface_uuid} ? $parameter->{interface_uuid} : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
id => $id, id => $id,
network_interface_bond_uuid => $network_interface_bond_uuid, network_interface_bond_uuid => $network_interface_bond_uuid,
network_interface_bridge_uuid => $network_interface_bridge_uuid, network_interface_bridge_uuid => $network_interface_bridge_uuid,
network_interface_current_name => $network_interface_current_name, network_interface_duplex => $network_interface_duplex,
network_interface_duplex => $network_interface_duplex, network_interface_host_uuid => $network_interface_host_uuid,
network_interface_host_uuid => $network_interface_host_uuid, network_interface_link_state => $network_interface_link_state,
network_interface_link_state => $network_interface_link_state, network_interface_operational => $network_interface_operational,
network_interface_operational => $network_interface_operational, network_interface_mac_address => $network_interface_mac_address,
network_interface_mac_address => $network_interface_mac_address, network_interface_medium => $network_interface_medium,
network_interface_medium => $network_interface_medium, network_interface_mtu => $network_interface_mtu,
network_interface_mtu => $network_interface_mtu, network_interface_name => $network_interface_name,
network_interface_requested_name => $network_interface_requested_name, network_interface_speed => $network_interface_speed,
network_interface_speed => $network_interface_speed, network_interface_uuid => $network_interface_uuid,
network_interface_uuid => $network_interface_uuid,
}}); }});
# I will need a MAC address and a UUID. If I don't have one, use the other to look it up. # I will need a MAC address and a UUID. If I don't have one, use the other to look it up.
@ -1568,8 +1562,7 @@ sub insert_or_update_network_interfaces
SELECT SELECT
network_interface_host_uuid, network_interface_host_uuid,
network_interface_mac_address, network_interface_mac_address,
network_interface_current_name, network_interface_name,
network_interface_requested_name,
network_interface_speed, network_interface_speed,
network_interface_mtu, network_interface_mtu,
network_interface_link_state, network_interface_link_state,
@ -1593,104 +1586,97 @@ WHERE
}}); }});
foreach my $row (@{$results}) foreach my $row (@{$results})
{ {
my $old_network_interface_host_uuid = $row->[0]; my $old_network_interface_host_uuid = $row->[0];
my $old_network_interface_mac_address = $row->[1]; my $old_network_interface_mac_address = $row->[1];
my $old_network_interface_current_name = $row->[2]; my $old_network_interface_name = $row->[2];
my $old_network_interface_requested_name = defined $row->[3] ? $row->[3] : ""; my $old_network_interface_speed = $row->[3];
my $old_network_interface_speed = $row->[4]; my $old_network_interface_mtu = defined $row->[4] ? $row->[4] : "";
my $old_network_interface_mtu = defined $row->[5] ? $row->[5] : ""; my $old_network_interface_link_state = $row->[5];
my $old_network_interface_link_state = $row->[6]; my $old_network_interface_operational = $row->[6];
my $old_network_interface_operational = $row->[7]; my $old_network_interface_duplex = $row->[7];
my $old_network_interface_duplex = $row->[8]; my $old_network_interface_medium = defined $row->[8] ? $row->[8] : "";
my $old_network_interface_medium = defined $row->[9] ? $row->[9] : ""; my $old_network_interface_bond_uuid = defined $row->[9] ? $row->[9] : "";
my $old_network_interface_bond_uuid = defined $row->[10] ? $row->[10] : ""; my $old_network_interface_bridge_uuid = defined $row->[10] ? $row->[10] : "";
my $old_network_interface_bridge_uuid = defined $row->[10] ? $row->[11] : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
old_network_interface_host_uuid => $old_network_interface_host_uuid, old_network_interface_host_uuid => $old_network_interface_host_uuid,
old_network_interface_mac_address => $old_network_interface_mac_address, old_network_interface_mac_address => $old_network_interface_mac_address,
old_network_interface_current_name => $old_network_interface_current_name, old_network_interface_name => $old_network_interface_name,
old_network_interface_requested_name => $old_network_interface_requested_name, old_network_interface_speed => $old_network_interface_speed,
old_network_interface_speed => $old_network_interface_speed, old_network_interface_mtu => $old_network_interface_mtu,
old_network_interface_mtu => $old_network_interface_mtu, old_network_interface_link_state => $old_network_interface_link_state,
old_network_interface_link_state => $old_network_interface_link_state, old_network_interface_operational => $old_network_interface_operational,
old_network_interface_operational => $old_network_interface_operational, old_network_interface_duplex => $old_network_interface_duplex,
old_network_interface_duplex => $old_network_interface_duplex, old_network_interface_medium => $old_network_interface_medium,
old_network_interface_medium => $old_network_interface_medium, old_network_interface_bond_uuid => $old_network_interface_bond_uuid,
old_network_interface_bond_uuid => $old_network_interface_bond_uuid, old_network_interface_bridge_uuid => $old_network_interface_bridge_uuid,
old_network_interface_bridge_uuid => $old_network_interface_bridge_uuid,
}}); }});
# If the caller didn't pass some values, we'll treat the # If the caller didn't pass some values, we'll treat the
# Anything to update? This is a little extra complicated because if a variable was # Anything to update? This is a little extra complicated because if a variable was
# not passed in, we want to not compare it. # not passed in, we want to not compare it.
if ((($network_interface_bond_uuid ne "--") && ($network_interface_bond_uuid ne $old_network_interface_bond_uuid)) or if ((($network_interface_bond_uuid ne "--") && ($network_interface_bond_uuid ne $old_network_interface_bond_uuid)) or
(($network_interface_bridge_uuid ne "--") && ($network_interface_bridge_uuid ne $old_network_interface_bridge_uuid)) or (($network_interface_bridge_uuid ne "--") && ($network_interface_bridge_uuid ne $old_network_interface_bridge_uuid)) or
(($network_interface_current_name ne "--") && ($network_interface_current_name ne $old_network_interface_current_name)) or (($network_interface_name ne "--") && ($network_interface_name ne $old_network_interface_name)) or
(($network_interface_duplex ne "--") && ($network_interface_duplex ne $old_network_interface_duplex)) or (($network_interface_duplex ne "--") && ($network_interface_duplex ne $old_network_interface_duplex)) or
(($network_interface_link_state ne "--") && ($network_interface_link_state ne $old_network_interface_link_state)) or (($network_interface_link_state ne "--") && ($network_interface_link_state ne $old_network_interface_link_state)) or
(($network_interface_operational ne "--") && ($network_interface_operational ne $old_network_interface_operational)) or (($network_interface_operational ne "--") && ($network_interface_operational ne $old_network_interface_operational)) or
(($network_interface_mac_address ne "--") && ($network_interface_mac_address ne $old_network_interface_mac_address)) or (($network_interface_mac_address ne "--") && ($network_interface_mac_address ne $old_network_interface_mac_address)) or
(($network_interface_medium ne "--") && ($network_interface_medium ne $old_network_interface_medium)) or (($network_interface_medium ne "--") && ($network_interface_medium ne $old_network_interface_medium)) or
(($network_interface_mtu ne "--") && ($network_interface_mtu ne $old_network_interface_mtu)) or (($network_interface_mtu ne "--") && ($network_interface_mtu ne $old_network_interface_mtu)) or
(($network_interface_requested_name ne "--") && ($network_interface_requested_name ne $old_network_interface_requested_name)) or (($network_interface_speed ne "--") && ($network_interface_speed ne $old_network_interface_speed)) or
(($network_interface_speed ne "--") && ($network_interface_speed ne $old_network_interface_speed)) or ($network_interface_host_uuid ne $old_network_interface_host_uuid))
($network_interface_host_uuid ne $old_network_interface_host_uuid))
{ {
# UPDATE any rows passed to us. # UPDATE any rows passed to us.
my $query = " my $query = "
UPDATE UPDATE
network_interfaces network_interfaces
SET SET
network_interface_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_host_uuid).", network_interface_host_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_host_uuid).",
"; ";
if ($network_interface_bond_uuid ne "--") if ($network_interface_bond_uuid ne "--")
{ {
$query .= " network_interface_bond_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_bond_uuid).", \n"; $query .= " network_interface_bond_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_bond_uuid).", \n";
} }
if ($network_interface_bridge_uuid ne "--") if ($network_interface_bridge_uuid ne "--")
{ {
$query .= " network_interface_bridge_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_bridge_uuid).", \n"; $query .= " network_interface_bridge_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_bridge_uuid).", \n";
} }
if ($network_interface_current_name ne "--") if ($network_interface_name ne "--")
{ {
$query .= " network_interface_current_name = ".$an->data->{sys}{use_db_fh}->quote($network_interface_current_name).", \n"; $query .= " network_interface_name = ".$an->data->{sys}{use_db_fh}->quote($network_interface_name).", \n";
} }
if ($network_interface_duplex ne "--") if ($network_interface_duplex ne "--")
{ {
$query .= " network_interface_duplex = ".$an->data->{sys}{use_db_fh}->quote($network_interface_duplex).", \n"; $query .= " network_interface_duplex = ".$an->data->{sys}{use_db_fh}->quote($network_interface_duplex).", \n";
} }
if ($network_interface_link_state ne "--") if ($network_interface_link_state ne "--")
{ {
$query .= " network_interface_link_state = ".$an->data->{sys}{use_db_fh}->quote($network_interface_link_state).", \n"; $query .= " network_interface_link_state = ".$an->data->{sys}{use_db_fh}->quote($network_interface_link_state).", \n";
} }
if ($network_interface_operational ne "--") if ($network_interface_operational ne "--")
{ {
$query .= " network_interface_operational = ".$an->data->{sys}{use_db_fh}->quote($network_interface_operational).", \n"; $query .= " network_interface_operational = ".$an->data->{sys}{use_db_fh}->quote($network_interface_operational).", \n";
} }
if ($network_interface_mac_address ne "--") if ($network_interface_mac_address ne "--")
{ {
$query .= " network_interface_mac_address = ".$an->data->{sys}{use_db_fh}->quote($network_interface_mac_address).", \n"; $query .= " network_interface_mac_address = ".$an->data->{sys}{use_db_fh}->quote($network_interface_mac_address).", \n";
} }
if ($network_interface_medium ne "--") if ($network_interface_medium ne "--")
{ {
$query .= " network_interface_medium = ".$an->data->{sys}{use_db_fh}->quote($network_interface_medium).", \n"; $query .= " network_interface_medium = ".$an->data->{sys}{use_db_fh}->quote($network_interface_medium).", \n";
} }
if ($network_interface_mtu ne "--") if ($network_interface_mtu ne "--")
{ {
$query .= " network_interface_mtu = ".$an->data->{sys}{use_db_fh}->quote($network_interface_mtu).", \n"; $query .= " network_interface_mtu = ".$an->data->{sys}{use_db_fh}->quote($network_interface_mtu).", \n";
}
if ($network_interface_requested_name ne "--")
{
$query .= " network_interface_requested_name = ".$an->data->{sys}{use_db_fh}->quote($network_interface_requested_name).", \n";
} }
if ($network_interface_speed ne "--") if ($network_interface_speed ne "--")
{ {
$query .= " network_interface_speed = ".$an->data->{sys}{use_db_fh}->quote($network_interface_speed).", \n"; $query .= " network_interface_speed = ".$an->data->{sys}{use_db_fh}->quote($network_interface_speed).", \n";
} }
$query .= " modified_date = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{db_timestamp})." $query .= " modified_date = ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{db_timestamp})."
WHERE WHERE
network_interface_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_uuid)." network_interface_uuid = ".$an->data->{sys}{use_db_fh}->quote($network_interface_uuid)."
;"; ;";
$query =~ s/'NULL'/NULL/g; $query =~ s/'NULL'/NULL/g;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
@ -1710,34 +1696,33 @@ WHERE
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_mac_address" }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_mac_address" }});
return(""); return("");
} }
if (($network_interface_current_name eq "--") or (not $network_interface_current_name)) if (($network_interface_name eq "--") or (not $network_interface_name))
{ {
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_current_name" }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_name" }});
return(""); return("");
} }
# Convert unpassed values to their defaults. # Convert unpassed values to their defaults.
$network_interface_bond_uuid = "NULL" if $network_interface_bond_uuid eq "--"; $network_interface_bond_uuid = "NULL" if $network_interface_bond_uuid eq "--";
$network_interface_bridge_uuid = "NULL" if $network_interface_bridge_uuid eq "--"; $network_interface_bridge_uuid = "NULL" if $network_interface_bridge_uuid eq "--";
$network_interface_duplex = "unknown" if $network_interface_duplex eq "--"; $network_interface_duplex = "unknown" if $network_interface_duplex eq "--";
$network_interface_link_state = 0 if $network_interface_link_state eq "--"; $network_interface_link_state = 0 if $network_interface_link_state eq "--";
$network_interface_operational = "unknown" if $network_interface_operational eq "--"; $network_interface_operational = "unknown" if $network_interface_operational eq "--";
$network_interface_medium = "" if $network_interface_medium eq "--"; $network_interface_medium = "" if $network_interface_medium eq "--";
$network_interface_requested_name = "" if $network_interface_requested_name eq "--"; $network_interface_speed = 0 if $network_interface_speed eq "--";
$network_interface_speed = 0 if $network_interface_speed eq "--"; $network_interface_mtu = 0 if $network_interface_mtu eq "--";
$network_interface_mtu = 0 if $network_interface_mtu eq "--";
# Make sure the UUIDs are sane. # Make sure the UUIDs are sane.
if (($network_interface_bond_uuid ne "NULL") && (not $an->Validate->is_uuid({uuid => $network_interface_bond_uuid}))) if (($network_interface_bond_uuid ne "NULL") && (not $an->Validate->is_uuid({uuid => $network_interface_bond_uuid})))
{ {
# Bad UUID. # Bad UUID.
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_current_name", uuid => $network_interface_bond_uuid }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_name", uuid => $network_interface_bond_uuid }});
return(""); return("");
} }
if (($network_interface_bridge_uuid ne "NULL") && (not $an->Validate->is_uuid({uuid => $network_interface_bridge_uuid}))) if (($network_interface_bridge_uuid ne "NULL") && (not $an->Validate->is_uuid({uuid => $network_interface_bridge_uuid})))
{ {
# Bad UUID. # Bad UUID.
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_current_name", uuid => $network_interface_bridge_uuid }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_name", uuid => $network_interface_bridge_uuid }});
return(""); return("");
} }
@ -1752,7 +1737,7 @@ INSERT INTO
network_interface_uuid, network_interface_uuid,
network_interface_bond_uuid, network_interface_bond_uuid,
network_interface_bridge_uuid, network_interface_bridge_uuid,
network_interface_current_name, network_interface_name,
network_interface_duplex, network_interface_duplex,
network_interface_host_uuid, network_interface_host_uuid,
network_interface_link_state, network_interface_link_state,
@ -1760,14 +1745,13 @@ INSERT INTO
network_interface_mac_address, network_interface_mac_address,
network_interface_medium, network_interface_medium,
network_interface_mtu, network_interface_mtu,
network_interface_requested_name,
network_interface_speed, network_interface_speed,
modified_date modified_date
) VALUES ( ) VALUES (
".$an->data->{sys}{use_db_fh}->quote($network_interface_uuid).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_uuid).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_bond_uuid).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_bond_uuid).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_bridge_uuid).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_bridge_uuid).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_current_name).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_name).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_duplex).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_duplex).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_host_uuid).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_host_uuid).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_link_state).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_link_state).",
@ -1775,7 +1759,6 @@ INSERT INTO
".$an->data->{sys}{use_db_fh}->quote($network_interface_mac_address).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_mac_address).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_medium).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_medium).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_mtu).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_mtu).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_requested_name).",
".$an->data->{sys}{use_db_fh}->quote($network_interface_speed).", ".$an->data->{sys}{use_db_fh}->quote($network_interface_speed).",
".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{db_timestamp})." ".$an->data->{sys}{use_db_fh}->quote($an->data->{sys}{db_timestamp})."
); );
@ -2037,7 +2020,7 @@ sub insert_or_update_variables
my $self = shift; my $self = shift;
my $parameter = shift; my $parameter = shift;
my $an = $self->parent; my $an = $self->parent;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0125", variables => { method => "Database->insert_or_update_variables()" }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0125", variables => { method => "Database->insert_or_update_variables()" }});
my $variable_uuid = defined $parameter->{variable_uuid} ? $parameter->{variable_uuid} : ""; my $variable_uuid = defined $parameter->{variable_uuid} ? $parameter->{variable_uuid} : "";
my $variable_name = defined $parameter->{variable_name} ? $parameter->{variable_name} : ""; my $variable_name = defined $parameter->{variable_name} ? $parameter->{variable_name} : "";
@ -2804,7 +2787,7 @@ sub read_variable
SELECT SELECT
variable_value, variable_value,
variable_uuid, variable_uuid,
round(extract(epoch from modified_date)) round(extract(epoch from modified_date)) AS mtime
FROM FROM
variables variables
WHERE "; WHERE ";
@ -2828,13 +2811,13 @@ AND
} }
} }
$query .= ";"; $query .= ";";
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0124", variables => { query => $query }});
my $variable_value = ""; my $variable_value = "";
my $modified_date = ""; my $modified_date = "";
my $results = $an->Database->query({id => $id, query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $an->Database->query({id => $id, query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
@ -2843,7 +2826,7 @@ AND
$variable_value = defined $row->[0] ? $row->[0] : ""; $variable_value = defined $row->[0] ? $row->[0] : "";
$variable_uuid = $row->[1]; $variable_uuid = $row->[1];
$modified_date = $row->[2]; $modified_date = $row->[2];
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
variable_value => $variable_value, variable_value => $variable_value,
variable_uuid => $variable_uuid, variable_uuid => $variable_uuid,
modified_date => $modified_date, modified_date => $modified_date,

@ -356,23 +356,45 @@ sub host_uuid
} }
elsif (not $an->data->{HOST}{UUID}) elsif (not $an->data->{HOST}{UUID})
{ {
# Read dmidecode # Read dmidecode if I am root, and the cache if not.
my $uuid = ""; my $uuid = "";
my $shell_call = $an->data->{path}{exe}{dmidecode}." --string system-uuid"; if (($< == 0) or ($> == 0))
#print $THIS_FILE." ".__LINE__."; [ Debug ] - shell_call: [$shell_call]\n";
open(my $file_handle, $shell_call." 2>&1 |") or warn $THIS_FILE." ".__LINE__."; [ Warning ] - Failed to call: [".$shell_call."], the error was: $!\n";
while(<$file_handle>)
{ {
# This should never be hit... my $shell_call = $an->data->{path}{exe}{dmidecode}." --string system-uuid";
chomp; #print $THIS_FILE." ".__LINE__."; [ Debug ] - shell_call: [$shell_call]\n";
$uuid = lc($_); open(my $file_handle, $shell_call." 2>&1 |") or warn $THIS_FILE." ".__LINE__."; [ Warning ] - Failed to call: [".$shell_call."], the error was: $!\n";
while(<$file_handle>)
{
# This should never be hit...
chomp;
$uuid = lc($_);
}
close $file_handle;
}
else
{
# Not running as root, so I have to rely on the cache file, or die if it doesn't
# exist.
if (not -e $an->data->{path}{data}{host_uuid})
{
# We're done.
}
else
{
$uuid = $an->Storage->read_file({ file => $an->data->{path}{data}{host_uuid} });
}
} }
close $file_handle;
if ($uuid) if ($an->Validate->is_uuid({uuid => $uuid}))
{ {
$an->data->{HOST}{UUID} = $uuid; $an->data->{HOST}{UUID} = $uuid;
} }
else
{
# Bad UUID.
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0134", variables => { uuid => $uuid }});
$an->data->{HOST}{UUID} = "";
}
} }
return($an->data->{HOST}{UUID}); return($an->data->{HOST}{UUID});

@ -640,10 +640,18 @@ If it fails to find the file, or the file is not readable, 'C<< !!error!! >>' is
Parameters; Parameters;
=head3 cache (optional)
This is an optional parameter that controls whether the file is cached in case something else tries to read the same file later. By default, all read files are cached. Set this to C<< 0 >> to disable caching. This should only be needed when reading large files.
=head3 file (required) =head3 file (required)
This is the name of the file to read. This is the name of the file to read.
=head3 force_read (optional)
This is an otpional parameter that, if set, forces the file to be read, bypassing cache if it exists. Set this to C<< 1 >> to bypass the cache.
=cut =cut
sub read_file sub read_file
{ {
@ -651,9 +659,15 @@ sub read_file
my $parameter = shift; my $parameter = shift;
my $an = $self->parent; my $an = $self->parent;
my $body = ""; my $body = "";
my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $cache = defined $parameter->{cache} ? $parameter->{cache} : 1;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }}); my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $force_read = defined $parameter->{force_read} ? $parameter->{force_read} : 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
cache => $cache,
file => $file,
force_read => $force_read,
}});
if (not $file) if (not $file)
{ {
@ -671,18 +685,35 @@ sub read_file
return("!!error!!"); return("!!error!!");
} }
my $shell_call = $file; # If I've read this before, don't read it again.
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0012", variables => { shell_call => $shell_call }}); if ((exists $an->data->{cache}{file}{$file}) && (not $force_read))
open (my $file_handle, "<", $shell_call) or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0015", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{ {
chomp; # Use the cache
my $line = $_; $body = $an->data->{cache}{file}{$file};
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0023", variables => { line => $line }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { body => $body }});
$body .= $line."\n"; }
else
{
# Read from disk.
my $shell_call = $file;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0012", variables => { shell_call => $shell_call }});
open (my $file_handle, "<", $shell_call) or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0015", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
chomp;
my $line = $_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0023", variables => { line => $line }});
$body .= $line."\n";
}
close $file_handle;
$body =~ s/\n$//s;
if ($cache)
{
$an->data->{cache}{file}{$file} = $body;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "cache::file::$file" => $an->data->{cache}{file}{$file} }});
}
} }
close $file_handle;
$body =~ s/\n$//s;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { body => $body }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { body => $body }});
return($body); return($body);

@ -179,14 +179,10 @@ sub get
if (not $error) if (not $error)
{ {
my $in_template = 0; my $in_template = 0;
my $shell_call = $source; my $template_file = $an->Storage->read_file({file => $source});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0012", variables => { shell_call => $shell_call }}); foreach my $line (split/\n/, $template_file)
open (my $file_handle, "<", $shell_call) or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0015", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{ {
chomp;
my $line = $_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0023", variables => { line => $line }}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0023", variables => { line => $line }});
if ($line =~ /^<!-- start $name -->/) if ($line =~ /^<!-- start $name -->/)
{ {
@ -206,7 +202,6 @@ sub get
} }
} }
} }
close $file_handle;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }});
# Now that I have the skin, inject my variables. We'll use Words->string() to do this for us. # Now that I have the skin, inject my variables. We'll use Words->string() to do this for us.
@ -416,7 +411,7 @@ sub skin
my $debug = 3; my $debug = 3;
my $fatal = defined $parameter->{fatal} ? $parameter->{fatal} : 1; my $fatal = defined $parameter->{fatal} ? $parameter->{fatal} : 1;
my $set = defined $parameter->{set} ? $parameter->{set} : ""; my $set = defined $parameter->{set} ? $parameter->{set} : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { fatal => $fatal, file => $set }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { fatal => $fatal, set => $set }});
if ($set) if ($set)
{ {

@ -181,7 +181,7 @@ The database connection error was:
<key name="log_0110">ScanCore database: [#!variable!database!#] created.</key> <key name="log_0110">ScanCore database: [#!variable!database!#] created.</key>
<key name="log_0111">[ Warning ] - Failed to reload the Postgres server. Please check the system logs for details. The updated configuration is probably not active yet.</key> <key name="log_0111">[ Warning ] - Failed to reload the Postgres server. Please check the system logs for details. The updated configuration is probably not active yet.</key>
<key name="log_0112">Reloaded the PostgreSQL database server.</key> <key name="log_0112">Reloaded the PostgreSQL database server.</key>
<key name="log_0113"><![CDATA[[ Note ] - The 'Database->configure_pgsql() method was called but the parent program is not running with root priviledges. Returning without doing anything.]]>.</key> <key name="log_0113"><![CDATA[[ Note ] - The 'Database->configure_pgsql() method was called but the parent program is not running with root priviledges. Returning without doing anything.]]></key>
<key name="log_0114"><![CDATA[The program: [#!data!path::exe::an-report-memory!#] must be called with '--program <name>', but no program name was read in.]]></key> <key name="log_0114"><![CDATA[The program: [#!data!path::exe::an-report-memory!#] must be called with '--program <name>', but no program name was read in.]]></key>
<key name="log_0115">#!variable!program!# has started.</key> <key name="log_0115">#!variable!program!# has started.</key>
<key name="log_0116"><![CDATA[The method: [#!variable!method!#] was passed the parameter: [#!variable!parameter!#] with the value: [#!variable!value!#], which is invalid.]]></key> <key name="log_0116"><![CDATA[The method: [#!variable!method!#] was passed the parameter: [#!variable!parameter!#] with the value: [#!variable!value!#], which is invalid.]]></key>
@ -199,6 +199,10 @@ The database connection error was:
<key name="log_0128">Firewalld was not running, and 'sys::daemons::restart_firewalld = 0' is set. NOT starting it.</key> <key name="log_0128">Firewalld was not running, and 'sys::daemons::restart_firewalld = 0' is set. NOT starting it.</key>
<key name="log_0129">all</key> <!-- Used when logging DB writes to all DBs --> <key name="log_0129">all</key> <!-- Used when logging DB writes to all DBs -->
<key name="log_0130"><![CDATA[[ Error ] - The method: [#!variable!method!#] was called and the parameter: [#!variable!parameter!#] was passed an invalid UUID: [#!variable!uuid!#].]]></key> <key name="log_0130"><![CDATA[[ Error ] - The method: [#!variable!method!#] was called and the parameter: [#!variable!parameter!#] was passed an invalid UUID: [#!variable!uuid!#].]]></key>
<key name="log_0131">Entering function: [#!variable!function!#]</key>
<key name="log_0132">Connected to: [#!variable!connections!#] database(s).</key>
<key name="log_0133">Failed to read the system UUID. Received a non-UUID string: [#!variable!uuid!#]. Is the user: [#!variable!user!#] in the 'kmem' group?</key>
<key name="log_0134">The read host UUID: [#!variable!uuid!#] does not appear to be a valid UUID.</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>

@ -1,5 +1,10 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
# Exit codes;
# 0 == OK
# 1 == Host UUID not available yet.
#
use strict; use strict;
use warnings; use warnings;
use AN::Tools; use AN::Tools;
@ -17,12 +22,29 @@ my $an = AN::Tools->new();
# Print the html headers, with a new line to break the header from the body. # Print the html headers, with a new line to break the header from the body.
print $an->Template->get({file => "shared.html", name => "http_headers"})."\n"; print $an->Template->get({file => "shared.html", name => "http_headers"})."\n";
# Set the log level to 2 # Set the log level to 2. Setting 3 slows he program down a LOT.
$an->Log->level({set => 2}); $an->Log->level({set => 2});
# Read in our words file. # Read in our words file.
$an->Words->read({file => $an->data->{path}{directories}{'cgi-bin'}."/words.xml"}); $an->Words->read({file => $an->data->{path}{directories}{'cgi-bin'}."/words.xml"});
# Read the config and then connect to the database.
$an->Storage->read_config({file => "/etc/striker/striker.conf"});
# Make sure I can read the host UUID.
if (not $an->Get->host_uuid)
{
# Too early, exit.
print $an->Words->string({key => "striker_error_0002"});
exit(1);
}
my $connections = $an->Database->connect({
sql_file => $an->data->{sys}{database}{schema},
test_table => "network_interfaces",
});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132", variables => { connections => $connections }});
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete. # Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1; $| = 1;
@ -402,6 +424,7 @@ sub sanity_check_step2
sub sanity_check_step1 sub sanity_check_step1
{ {
my ($an) = @_; my ($an) = @_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0131", variables => { function => "sanity_check_step1()" }});
# This will flip if we run into a problem. # This will flip if we run into a problem.
my $sane = 1; my $sane = 1;
@ -413,6 +436,20 @@ sub sanity_check_step1
$sane = 0; $sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::organization::alert" => $an->data->{cgi}{organization}{alert} }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::organization::alert" => $an->data->{cgi}{organization}{alert} }});
} }
else
{
# Record the answer.
$an->Database->insert_or_update_variables({
variable_name => "form::config_step1::organization::value",
variable_value => $an->data->{cgi}{organization}{value},
variable_default => "",
variable_description => "striker_0004",
variable_section => "config_step1",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
# The prefix needs to be alphanumeric and be between 1 ~ 5 chatacters. # The prefix needs to be alphanumeric and be between 1 ~ 5 chatacters.
if ((not $an->Validate->is_alphanumeric({string => $an->data->{cgi}{prefix}{value}})) or (length($an->data->{cgi}{prefix}{value}) > 5)) if ((not $an->Validate->is_alphanumeric({string => $an->data->{cgi}{prefix}{value}})) or (length($an->data->{cgi}{prefix}{value}) > 5))
@ -421,6 +458,20 @@ sub sanity_check_step1
$sane = 0; $sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::prefix::alert" => $an->data->{cgi}{prefix}{alert} }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::prefix::alert" => $an->data->{cgi}{prefix}{alert} }});
} }
else
{
# Record the answer.
$an->Database->insert_or_update_variables({
variable_name => "form::config_step1::prefix::value",
variable_value => $an->data->{cgi}{prefix}{value},
variable_default => "",
variable_description => "striker_0006",
variable_section => "config_step1",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
# We can use Validate to check the domain. # We can use Validate to check the domain.
if (not $an->Validate->is_domain_name({name => $an->data->{cgi}{domain}{value}})) if (not $an->Validate->is_domain_name({name => $an->data->{cgi}{domain}{value}}))
@ -429,6 +480,20 @@ sub sanity_check_step1
$sane = 0; $sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::domain::alert" => $an->data->{cgi}{domain}{alert} }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::domain::alert" => $an->data->{cgi}{domain}{alert} }});
} }
else
{
# Record the answer.
$an->Database->insert_or_update_variables({
variable_name => "form::config_step1::domain::value",
variable_value => $an->data->{cgi}{domain}{value},
variable_default => "",
variable_description => "striker_0008",
variable_section => "config_step1",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
# The sequence and IFN count need to be integers. # The sequence and IFN count need to be integers.
if (not $an->Validate->is_positive_integer({number => $an->data->{cgi}{sequence}{value}})) if (not $an->Validate->is_positive_integer({number => $an->data->{cgi}{sequence}{value}}))
@ -437,6 +502,21 @@ sub sanity_check_step1
$sane = 0; $sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::sequence::alert" => $an->data->{cgi}{sequence}{alert} }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::sequence::alert" => $an->data->{cgi}{sequence}{alert} }});
} }
else
{
# Record the answer.
$an->Database->insert_or_update_variables({
variable_name => "form::config_step1::sequence::value",
variable_value => $an->data->{cgi}{sequence}{value},
variable_default => "",
variable_description => "striker_0010",
variable_section => "config_step1",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
if (not $an->Validate->is_positive_integer({number => $an->data->{cgi}{ifn_count}{value}})) if (not $an->Validate->is_positive_integer({number => $an->data->{cgi}{ifn_count}{value}}))
{ {
$an->data->{cgi}{ifn_count}{alert} = 1; $an->data->{cgi}{ifn_count}{alert} = 1;
@ -468,6 +548,20 @@ sub sanity_check_step1
$an->data->{cgi}{ifn_count}{alert} = 1; $an->data->{cgi}{ifn_count}{alert} = 1;
$sane = 0; $sane = 0;
} }
else
{
# Record the answer.
$an->Database->insert_or_update_variables({
variable_name => "form::config_step1::ifn_count::value",
variable_value => $an->data->{cgi}{ifn_count}{value},
variable_default => "",
variable_description => "striker_0012",
variable_section => "config_step1",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
update_value_only => 1,
});
}
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { sane => $sane }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { sane => $sane }});
return($sane); return($sane);
@ -478,13 +572,54 @@ sub config_step1
{ {
my ($an) = @_; my ($an) = @_;
# TODO: Later, this will be a check to see if we've configured this Striker before and, if so, offer if (not $an->data->{cgi}{'next'}{value})
# an option to restore.
my $reload_old_config = "";
if (1)
{ {
### TODO: ... # First load. See if we can read old data.
# Old config exists. Load the detail and present the option to reload. my ($organization) = $an->Database->read_variable({
variable_name => "form::config_step1::organization::value",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
});
my ($prefix) = $an->Database->read_variable({
variable_name => "form::config_step1::prefix::value",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
});
my ($domain) = $an->Database->read_variable({
variable_name => "form::config_step1::domain::value",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
});
my ($sequence) = $an->Database->read_variable({
variable_name => "form::config_step1::sequence::value",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
});
my ($ifn_count) = $an->Database->read_variable({
variable_name => "form::config_step1::ifn_count::value",
variable_source_uuid => $an->Get->host_uuid,
variable_source_table => "hosts",
});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
organization => $organization,
prefix => $prefix,
domain => $domain,
sequence => $sequence,
ifn_count => $ifn_count,
}});
$an->data->{cgi}{organization}{value} = $organization ne "" ? $organization : "";
$an->data->{cgi}{prefix}{value} = $prefix ne "" ? $prefix : "";
$an->data->{cgi}{domain}{value} = $domain ne "" ? $domain : "";
$an->data->{cgi}{sequence}{value} = $sequence ne "" ? $sequence : 1;
$an->data->{cgi}{ifn_count}{value} = $ifn_count ne "" ? $ifn_count : 1;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::organization::value' => $an->data->{cgi}{organization}{value},
'cgi::prefix::value' => $an->data->{cgi}{prefix}{value},
'cgi::domain::value' => $an->data->{cgi}{domain}{value},
'cgi::sequence::value' => $an->data->{cgi}{sequence}{value},
'cgi::ifn_count::value' => $an->data->{cgi}{ifn_count}{value},
}});
} }
my $organization_class = $an->data->{cgi}{organization}{alert} ? "input_alert" : "input_clear"; my $organization_class = $an->data->{cgi}{organization}{alert} ? "input_alert" : "input_clear";
@ -528,7 +663,7 @@ sub config_step1
description => "#!string!striker_0010!#", description => "#!string!striker_0010!#",
value => defined $an->data->{cgi}{sequence}{value} ? $an->data->{cgi}{sequence}{value} : "", value => defined $an->data->{cgi}{sequence}{value} ? $an->data->{cgi}{sequence}{value} : "",
class => $sequence_class, class => $sequence_class,
extra => "maxlength=\"2\"", extra => "min=\"1\" max=\"24\"",
}}); }});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_domain => $say_domain }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_domain => $say_domain }});
my $ifn_count_class = $an->data->{cgi}{ifn_count}{alert} ? "input_alert" : "input_clear"; my $ifn_count_class = $an->data->{cgi}{ifn_count}{alert} ? "input_alert" : "input_clear";
@ -539,7 +674,7 @@ sub config_step1
description => "#!string!striker_0012!#", description => "#!string!striker_0012!#",
value => defined $an->data->{cgi}{ifn_count}{value} ? $an->data->{cgi}{ifn_count}{value} : "", value => defined $an->data->{cgi}{ifn_count}{value} ? $an->data->{cgi}{ifn_count}{value} : "",
class => $ifn_count_class, class => $ifn_count_class,
extra => "maxlength=\"2\"", extra => "min=\"1\" max=\"24\"",
}}); }});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_ifn_count => $say_ifn_count }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_ifn_count => $say_ifn_count }});

@ -70,6 +70,7 @@ This is the AN::Tools master 'words' file.
<!-- Errors --> <!-- Errors -->
<key name="striker_error_0001">There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network).</key> <key name="striker_error_0001">There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network).</key>
<key name="striker_error_0002">The local system UUID can't be read yet. This might be because the system is brand new and/or ScanCore hasn't run yet. Please try again in a minute.</key>
<!-- These are works and strings used by javascript/jqery --> <!-- These are works and strings used by javascript/jqery -->
<key name="js_0001">Up</key> <key name="js_0001">Up</key>

@ -27,7 +27,7 @@ $(function() {
} }
else else
{ {
alert('network status does not exist.'); //alert('network status strings not loaded.');
} }
if($("#disk_status").length) { if($("#disk_status").length) {
//alert('disk status exists.'); //alert('disk status exists.');

@ -10,8 +10,7 @@ CREATE TABLE network_interfaces (
network_interface_uuid uuid not null primary key, network_interface_uuid uuid not null primary key,
network_interface_host_uuid uuid not null, network_interface_host_uuid uuid not null,
network_interface_mac_address text not null, network_interface_mac_address text not null,
network_interface_current_name text not null, -- This is the current name of the interface. network_interface_name text not null, -- This is the current name of the interface.
network_interface_requested_name text, -- This is the name of the interface that the user requested. This will differ from the current name pending a commit request by the user.
network_interface_speed bigint not null, -- This is the speed, in bits-per-second, of the interface. network_interface_speed bigint not null, -- This is the speed, in bits-per-second, of the interface.
network_interface_mtu bigint, -- This is the MTU (Maximum Transmitable Size), in bytes, for this interface. network_interface_mtu bigint, -- This is the MTU (Maximum Transmitable Size), in bytes, for this interface.
network_interface_link_state text not null, -- 0 or 1 network_interface_link_state text not null, -- 0 or 1
@ -29,8 +28,7 @@ CREATE TABLE history.network_interfaces (
network_interface_uuid uuid not null, network_interface_uuid uuid not null,
network_interface_host_uuid uuid, network_interface_host_uuid uuid,
network_interface_mac_address text, network_interface_mac_address text,
network_interface_current_name text, network_interface_name text,
network_interface_requested_name text,
network_interface_speed bigint, network_interface_speed bigint,
network_interface_mtu bigint, network_interface_mtu bigint,
network_interface_link_state text, network_interface_link_state text,
@ -53,8 +51,7 @@ BEGIN
(network_interface_uuid, (network_interface_uuid,
network_interface_host_uuid, network_interface_host_uuid,
network_interface_mac_address, network_interface_mac_address,
network_interface_current_name, network_interface_name,
network_interface_requested_name,
network_interface_speed, network_interface_speed,
network_interface_mtu, network_interface_mtu,
network_interface_link_state, network_interface_link_state,
@ -68,8 +65,7 @@ BEGIN
(history_network_interfaces.network_interface_uuid, (history_network_interfaces.network_interface_uuid,
history_network_interfaces.network_interface_host_uuid, history_network_interfaces.network_interface_host_uuid,
history_network_interfaces.network_interface_mac_address, history_network_interfaces.network_interface_mac_address,
history_network_interfaces.network_interface_current_name, history_network_interfaces.network_interface_name,
history_network_interfaces.network_interface_requested_name,
history_network_interfaces.network_interface_speed, history_network_interfaces.network_interface_speed,
history_network_interfaces.network_interface_mtu, history_network_interfaces.network_interface_mtu,
history_network_interfaces.network_interface_link_state, history_network_interfaces.network_interface_link_state,

@ -31,7 +31,7 @@ $an->Log->level({set => 2});
$an->Log->secure({set => 1}); $an->Log->secure({set => 1});
# Paths # Paths
$an->data->{path}{tools}{'an-prep-database'} = "/usr/sbin/striker/scancore-database"; $an->data->{path}{tools}{'an-prep-database'} = "/usr/sbin/striker/scancore-database";
$an->data->{path}{tools}{'scancore-update-states'} = "/usr/sbin/striker/scancore-update-states"; $an->data->{path}{tools}{'scancore-update-states'} = "/usr/sbin/striker/scancore-update-states";
$an->data->{path}{config}{'striker.conf'} = "/etc/striker/striker.conf"; $an->data->{path}{config}{'striker.conf'} = "/etc/striker/striker.conf";
@ -309,6 +309,22 @@ if ($local_id)
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "warning_0001"}); $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "warning_0001"});
} }
} }
### TODO: This will need to set the proper SELinux context.
# Apache run scripts can't call the system UUID, so we'll write it to a text file.
if (not -e $an->data->{path}{data}{host_uuid})
{
$an->Storage->write_file({
file => $an->data->{path}{data}{host_uuid},
body => $an->Get->host_uuid,
user => "apache",
group => "apache",
mode => "0666",
overwrite => 0,
});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "message_0002", variables => { file => $an->data->{path}{configs}{'postgresql.conf'} }});
}
} }
else else
{ {

@ -94,14 +94,14 @@ sub report_network
}}); }});
$an->Database->insert_or_update_network_interfaces({ $an->Database->insert_or_update_network_interfaces({
network_interface_current_name => $interface, network_interface_name => $interface,
network_interface_duplex => $duplex, network_interface_duplex => $duplex,
network_interface_link_state => $link_state, network_interface_link_state => $link_state,
network_interface_operational => $operational, network_interface_operational => $operational,
network_interface_mac_address => $mac_address, network_interface_mac_address => $mac_address,
network_interface_medium => $media, network_interface_medium => $media,
network_interface_mtu => $mtu, network_interface_mtu => $mtu,
network_interface_speed => $speed, network_interface_speed => $speed,
}); });
$network_json .= " { \"name\":\"$interface\", \"mac\":\"$mac_address\", \"link\":\"$link_state\", \"mtu\":\"$mtu\" \"duplex\":\"$duplex\", \"state\":\"$operational\", \"speed\":\"$speed\", \"media\":\"$media\" },\n"; $network_json .= " { \"name\":\"$interface\", \"mac\":\"$mac_address\", \"link\":\"$link_state\", \"mtu\":\"$mtu\" \"duplex\":\"$duplex\", \"state\":\"$operational\", \"speed\":\"$speed\", \"media\":\"$media\" },\n";

Loading…
Cancel
Save