* Added the ability to store, edit and delete UPSes

** Created Database->get_upses() and ->insert_or_update_upses().
** Created Striker->get_ups_data(). This parses the special 'ups_XXXX' strings.
* Updated Validate->is_domain() and added ->is_host_name() to use the Data::Validate::Domain module (which is now required in the core RPM).
* Started work on manifest handling.
* Sorted the language keys alphabetically.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 1edf723ea5
commit e66bc32693
  1. 316
      Anvil/Tools/Database.pm
  2. 75
      Anvil/Tools/Striker.pm
  3. 90
      Anvil/Tools/Validate.pm
  4. 2
      Anvil/Tools/Words.pm
  5. 924
      cgi-bin/striker
  6. 591
      html/skins/alteeve/anvil.html
  7. 4
      html/skins/alteeve/config.html
  8. 3
      html/skins/alteeve/images/sources.txt
  9. BIN
      html/skins/alteeve/images/ups.png
  10. 6
      html/skins/alteeve/main.css
  11. 4
      html/skins/alteeve/striker.html
  12. 1
      rpm/SPECS/anvil.spec
  13. 48
      share/anvil.sql
  14. 1194
      share/words.xml
  15. 131
      tools/test.pl

@ -30,6 +30,7 @@ my $THIS_FILE = "Database.pm";
# get_mail_servers
# get_notifications
# get_recipients
# get_upses
# initialize
# insert_or_update_anvils
# insert_or_update_bridges
@ -50,6 +51,7 @@ my $THIS_FILE = "Database.pm";
# insert_or_update_recipients
# insert_or_update_sessions
# insert_or_update_states
# insert_or_update_upses
# insert_or_update_users
# insert_or_update_variables
# lock_file
@ -1576,6 +1578,7 @@ WHERE
return(0);
}
=head2 get_host_from_uuid
This takes a host UUID and returns the host's name. If there is a problem, or if the host UUID isn't found, an empty string is returned.
@ -2321,6 +2324,118 @@ FROM
}
=head2 get_upses
This loads the known UPSes (uninterruptible power supplies) into the C<< anvil::data >> hash at:
* upses::ups_uuid::<ups_uuid>::ups_name
* upses::ups_uuid::<ups_uuid>::ups_agent
* upses::ups_uuid::<ups_uuid>::ups_ip_address
* upses::ups_uuid::<ups_uuid>::modified_date
And, to allow for lookup by name;
* upses::ups_name::<ups_name>::ups_uuid
* upses::ups_name::<ups_name>::ups_agent
* upses::ups_name::<ups_name>::ups_ip_address
* upses::ups_name::<ups_name>::modified_date
If the hash was already populated, it is cleared before repopulating to ensure no stray data remains.
B<<Note>>: Deleted devices (ones where C<< ups_ip_address >> is set to C<< DELETED >>) are ignored. See the C<< include_deleted >> parameter to include them.
Parameters;
=head3 include_deleted (Optional, default 0)
If set to C<< 1 >>, deleted agents are included when loading the data. When C<< 0 >> is set, the default, any ups agent with C<< ups_ip_address >> set to C<< DELETED >> is ignored.
=cut
sub get_upses
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_host_from_uuid()" }});
my $include_deleted = defined $parameter->{include_deleted} ? $parameter->{include_deleted} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
include_deleted => $include_deleted,
}});
if (exists $anvil->data->{upses})
{
delete $anvil->data->{upses};
}
my $query = "
SELECT
ups_uuid,
ups_name,
ups_agent,
ups_ip_address,
modified_date
FROM
upses ";
if (not $include_deleted)
{
$query .= "
WHERE
ups_ip_address != 'DELETED'";
}
$query .= "
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, 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 => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $ups_uuid = $row->[0];
my $ups_name = $row->[1];
my $ups_agent = $row->[2];
my $ups_ip_address = $row->[3];
my $modified_date = $row->[4];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ups_uuid => $ups_uuid,
ups_name => $ups_name,
ups_agent => $ups_agent,
ups_ip_address => $ups_ip_address,
modified_date => $modified_date,
}});
# Record the data in the hash, too.
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_name} = $ups_name;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_agent} = $ups_agent;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_ip_address} = $ups_ip_address;
$anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date} = $modified_date;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"upses::ups_uuid::${ups_uuid}::ups_name" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_name},
"upses::ups_uuid::${ups_uuid}::ups_agent" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_agent},
"upses::ups_uuid::${ups_uuid}::ups_ip_address" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{ups_ip_address},
"upses::ups_uuid::${ups_uuid}::modified_date" => $anvil->data->{upses}{ups_uuid}{$ups_uuid}{modified_date},
}});
$anvil->data->{upses}{ups_name}{$ups_name}{ups_uuid} = $ups_uuid;
$anvil->data->{upses}{ups_name}{$ups_name}{ups_agent} = $ups_agent;
$anvil->data->{upses}{ups_name}{$ups_name}{ups_ip_address} = $ups_ip_address;
$anvil->data->{upses}{ups_name}{$ups_name}{modified_date} = $modified_date;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"upses::ups_name::${ups_name}::ups_uuid" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_uuid},
"upses::ups_name::${ups_name}::ups_agent" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_agent},
"upses::ups_name::${ups_name}::ups_ip_address" => $anvil->data->{upses}{ups_name}{$ups_name}{ups_ip_address},
"upses::ups_name::${ups_name}::modified_date" => $anvil->data->{upses}{ups_name}{$ups_name}{modified_date},
}});
}
return(0);
}
=head2 initialize
This will initialize a database using a given file.
@ -7399,6 +7514,207 @@ WHERE
}
=head2 insert_or_update_upses
This updates (or inserts) a record in the 'upses' table. The C<< ups_uuid >> UUID will be returned.
If there is an error, an empty string is returned.
Parameters;
=head3 uuid (optional)
If set, only the corresponding database will be written to.
=head3 file (optional)
If set, this is the file name logged as the source of any INSERTs or UPDATEs.
=head3 line (optional)
If set, this is the file line number logged as the source of any INSERTs or UPDATEs.
=head3 ups_agent (required)
This is the name of the ups agent to use when communicating with this ups device. The agent must be installed on any machine that may need to ups (or check the ups/power state of) a node.
=head3 ups_ip_address (optional, but generally required in practice)
This is the string that tells machines how to communicate / control the the ups device. This is used when configuring pacemaker's stonith (fencing).
The exact formatting needs to match the STDIN parameters supported by C<< ups_agent >>. Please see C<< STDIN PARAMETERS >> section of the ups agent man page for this device.
For example, this can be set to:
* C<< ip="10.201.11.1" lanplus="1" username="admin" password="super secret password"
B<< NOTES >>:
* If C<< password_script >> is used, it is required that the user has copied the script to the nodes.
* Do not use C<< action="..." >> or the ups agent name. If either is found in the string, they will be ignored.
* Do not use C<< delay >>. It will be determined automatically based on which node has the most servers running on it.
* If this is set to C<< DELETED >>, the ups device is considered no longer used and it will be ignored by C<< Database->get_upses() >>.
=head3 ups_name (required)
This is the name of the ups device. Genreally, this is the short host name of the device.
=head3 ups_uuid (required)
The default value is the ups's UUID. When passed, the specific record is updated.
=cut
sub insert_or_update_upses
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->insert_or_update_upses()" }});
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";
my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $line = defined $parameter->{line} ? $parameter->{line} : "";
my $ups_agent = defined $parameter->{ups_agent} ? $parameter->{ups_agent} : "";
my $ups_ip_address = defined $parameter->{ups_ip_address} ? $parameter->{ups_ip_address} : "";
my $ups_name = defined $parameter->{ups_name} ? $parameter->{ups_name} : "";
my $ups_uuid = defined $parameter->{ups_uuid} ? $parameter->{ups_uuid} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
uuid => $uuid,
file => $file,
line => $line,
ups_agent => $ups_agent,
ups_ip_address => $ups_ip_address =~ /passwork=/ ? $anvil->Log->is_secure($ups_ip_address) : $ups_ip_address,
ups_name => $ups_name,
ups_uuid => $ups_uuid,
}});
if (not $ups_agent)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_upses()", parameter => "ups_agent" }});
return("");
}
if (not $ups_name)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_upses()", parameter => "ups_name" }});
return("");
}
if (not $ups_ip_address)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_upses()", parameter => "ups_ip_address" }});
return("");
}
# Do we have a UUID?
if (not $ups_uuid)
{
### TODO: We might want to try finding it by the IP address, if the name doesn't match. This
### might cause issues though if different UPSes spanning different BCNs could be
### confused, perhaps?
my $query = "
SELECT
ups_uuid
FROM
upses
WHERE
ups_name = ".$anvil->Database->quote($ups_name)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
if ($count)
{
$ups_uuid = $results->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ups_uuid => $ups_uuid }});
}
}
# Do we have a UUID?
if ($ups_uuid)
{
# Yup. Has something changed?
my $query = "
SELECT
ups_agent,
ups_name,
ups_ip_address
FROM
upses
WHERE
ups_uuid = ".$anvil->Database->quote($ups_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({uuid => $uuid, query => $query, uuid => $uuid, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
foreach my $row (@{$results})
{
my $old_ups_agent = $row->[0];
my $old_ups_name = $row->[1];
my $old_ups_ip_address = $row->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
old_ups_agent => $old_ups_agent,
old_ups_name => $old_ups_name =~ /passw/ ? $anvil->Log->is_secure($old_ups_name) : $old_ups_name,
old_ups_ip_address => $old_ups_ip_address,
}});
if (($old_ups_agent ne $ups_agent) or
($old_ups_name ne $ups_name) or
($old_ups_ip_address ne $ups_ip_address))
{
# Clear the stop data.
my $query = "
UPDATE
upses
SET
ups_name = ".$anvil->Database->quote($ups_name).",
ups_ip_address = ".$anvil->Database->quote($ups_ip_address).",
ups_agent = ".$anvil->Database->quote($ups_agent).",
modified_date = ".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
WHERE
ups_uuid = ".$anvil->Database->quote($ups_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query =~ /passw/ ? $anvil->Log->is_secure($query) : $query }});
$anvil->Database->write({uuid => $uuid, query => $query, uuid => $uuid, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
}
}
else
{
# No, INSERT.
$ups_uuid = $anvil->Get->uuid();
my $query = "
INSERT INTO
upses
(
ups_uuid,
ups_name,
ups_ip_address,
ups_agent,
modified_date
) VALUES (
".$anvil->Database->quote($ups_uuid).",
".$anvil->Database->quote($ups_name).",
".$anvil->Database->quote($ups_ip_address).",
".$anvil->Database->quote($ups_agent).",
".$anvil->Database->quote($anvil->data->{sys}{database}{timestamp})."
);
";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query =~ /passw/ ? $anvil->Log->is_secure($query) : $query }});
$anvil->Database->write({uuid => $uuid, query => $query, uuid => $uuid, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
}
return($ups_uuid);
}
=head2 insert_or_update_users
This updates (or inserts) a record in the 'users' table. The C<< user_uuid >> referencing the database row will be returned.

@ -16,6 +16,7 @@ my $THIS_FILE = "Striker.pm";
# get_fence_data
# get_local_repo
# get_peer_data
# get_ups_data
# parse_all_status_json
=pod
@ -525,6 +526,78 @@ sub get_peer_data
return($connected, $data);
}
=head2 get_ups_data
This parses the special C<< ups_X >> string keys to create a list of supported UPSes (in ScanCore and Install Manifests).
Parsed data is stored in;
* C<< ups_data::<key>::agent >>
* C<< ups_data::<key>::brand >>
* C<< ups_data::<key>::description >>
The language used is the language returned by C<< Words->language() >>.
This method takes no parameters.
=cut
sub get_ups_data
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->get_ups_data()" }});
# In case we've loaded the data before, clear it.
if (exists $anvil->data->{ups_data})
{
delete $anvil->data->{ups_data};
}
my $language = $anvil->Words->language();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { language => $language }});
foreach my $word_file (sort {$a cmp $b} keys %{$anvil->data->{words}})
{
# Now loop through all keys looking for 'ups_*'.
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{words}{$word_file}{language}{$language}{key}})
{
next if $key !~ /^ups_(\d+)/;
# If we're here, we've got a UPS.
my $description = $anvil->data->{words}{$word_file}{language}{$language}{key}{$key}{content};
my $brand = $anvil->data->{words}{$word_file}{language}{$language}{key}{$key}{brand};
my $agent = $anvil->data->{words}{$word_file}{language}{$language}{key}{$key}{agent};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:brand' => $brand,
's2:agent' => $agent,
's3:description' => $description,
}});
$anvil->data->{ups_data}{$key}{agent} = $agent;
$anvil->data->{ups_data}{$key}{brand} = $brand;
$anvil->data->{ups_data}{$key}{description} = $description;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:ups_data::${key}::agent" => $anvil->data->{ups_data}{$key}{agent},
"s2:ups_data::${key}::brand" => $anvil->data->{ups_data}{$key}{brand},
"s3:ups_data::${key}::description" => $anvil->data->{ups_data}{$key}{description},
}});
# Make it easy to convert the agent to the brand.
$anvil->data->{ups_agent}{$agent}{brand} = $brand;
$anvil->data->{ups_agent}{$agent}{key} = $key;
$anvil->data->{ups_agent}{$agent}{description} = $description;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"ups_agent::${agent}::brand" => $anvil->data->{ups_agent}{$agent}{brand},
"ups_agent::${agent}::key" => $anvil->data->{ups_agent}{$agent}{key},
"ups_agent::${agent}::description" => $anvil->data->{ups_agent}{$agent}{description},
}});
}
}
return(0);
}
=head2 parse_all_status_json
This parses the c<< all_status.json >> file is a way that Striker can more readily use. If the read or parse failes, C<< 1 >> is returned. Otherwise C<< 0 >> is returned.
@ -538,7 +611,7 @@ sub parse_all_status_json
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->get_peer_data()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->parse_all_status_json()" }});
# Read it in
my $json_file = $anvil->data->{path}{directories}{status}."/".$anvil->data->{path}{json}{all_status};

@ -6,6 +6,7 @@ package Anvil::Tools::Validate;
use strict;
use warnings;
use Data::Dumper;
use Data::Validate::Domain qw(is_domain);
use Scalar::Util qw(weaken isweak);
use Mail::RFC822::Address qw(valid validlist);
@ -18,6 +19,7 @@ my $THIS_FILE = "Validate.pm";
# is_domain_name
# is_email
# is_hex
# is_host_name
# is_ipv4
# is_mac
# is_positive_integer
@ -305,17 +307,29 @@ sub is_domain_name
$valid = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
}
elsif (($name !~ /^((([a-z]|[0-9]|\-)+)\.)+([a-z])+$/i) && (($name !~ /^\w+$/) && ($name !~ /-/)))
else
{
# Underscores are allowd in domain names, but not host names. We disable TLD checks as we
# frequently use '.remote', '.bcn', etc.
### TODO: Add a 'strict' parameter to control this) and/or support domain_private_tld
my %options = (domain_allow_underscore => 1, domain_disable_tld_validation => 1);
my $dvd = Data::Validate::Domain->new(%options);
my $test = $dvd->is_domain($name);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { test => $test }});
if (not $test)
{
# Doesn't appear to be valid.
$valid = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
return($valid);
}
=head2 is_hex
Checks if the passed-in string contains only hexidecimal characters. A prefix of C<< 0x >> is allowed.
@ -366,6 +380,80 @@ sub is_hex
}
=head2 is_host_name
Checks if the passed-in string is a valid host name. Returns 'C<< 1 >>' if OK, 'C<< 0 >>' if not.
B<NOTE>: If this method receives a full domain name, the host name is checked in this method and the domain (anything after the first C<< . >>) is tested using C<< Validate->is_domain_name >>. If either fails, C<< 0 >> is returned.
$name = "an-a05n01";
if ($anvil->Validate->is_host_name({name => $name}))
{
print "The host name: [$name] is valid!\n";
}
Parameters;
=head3 name (required)
This is the host name to validate.
=cut
sub is_host_name
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $valid = 1;
my $name = $parameter->{name} ? $parameter->{name} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { name => $name }});
my $domain = "";
if ($name =~ /\./)
{
($name, $domain) = ($name =~ /^(.*?)\.(.*)$/);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
name => $name,
domain => $domain,
}});
}
if ($domain)
{
$valid = $anvil->Validate->is_domain_name({
name => $domain,
debug => $debug,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
}
if (not $name)
{
$valid = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
}
else
{
# Underscores are allowd in domain names, but not host names.
my %options = (domain_allow_underscore => 1);
my $dvd = Data::Validate::Domain->new(%options);
my $test = $dvd->is_hostname($name);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { test => $test }});
if (not $test)
{
# Doesn't appear to be valid.
$valid = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { valid => $valid }});
return($valid);
}
=head2 is_email
Checks if the passed-in string is a valid address. Returns 'C<< 1 >>' if OK, 'C<< 0 >>' if not.

@ -224,7 +224,7 @@ sub key
This sets or returns the output language ISO code.
Get the current log language;
Get the current active language;
my $language = $anvil->Words->language;

File diff suppressed because it is too large Load Diff

@ -26,10 +26,18 @@
</tr>
<tr>
<td class="main_option_icon">
<a href="?anvil=true&task=create&new=step1"><img src="#!data!skin::url!#/images/manifest.png" class="top_icon" ></a>
<a href="?anvil=true&task=upses"><img src="#!data!skin::url!#/images/ups.png" class="top_icon" ></a>
</td>
<td class="main_option">
<a href="?anvil=true&task=create&new=step1">#!string!striker_0204!#</a>
<a href="?anvil=true&task=upses">#!string!striker_0231!# #!string!striker_0237!#</a>
</td>
</tr>
<tr>
<td class="main_option_icon">
<a href="?anvil=true&task=manifests&manifest=new"><img src="#!data!skin::url!#/images/manifest.png" class="top_icon" ></a>
</td>
<td class="main_option">
<a href="?anvil=true&task=manifests&manifest=new">#!string!striker_0204!#</a>
</td>
</tr>
<tr>
@ -58,6 +66,91 @@
</table>
<!-- end create-menu -->
<!-- start new-manifest-step1 -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td class="title">
#!string!striker_0226!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td class="description">
#!string!striker_0227!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
<form name="manifest_step1" action="" method="post">
<table align="center" class="anvil_main_menu">
<tr>
<td class="header">
<!-- prefix -->
#!string!striker_0228!#
</td>
<td>
&nbsp;
</td>
<td class="header">
<!-- Sequence -->
#!string!striker_0229!#
</td>
</tr>
<!-- TODO: Left off here, add IFN count and make the above "[ ]-anvil-[ ]". -->
<tr>
<td>
<input type="text" name="prefix" id="prefix" value="#!variable!prefix!#" placeholder="xx-" />
<input type="hidden" name="default_prefix" id="default_prefix" value="#!variable!default_prefix!#"/>
</td>
</tr>
<tr>
<td>
<input type="text" name="sequence" id="sequence" value="#!variable!sequence!#" placeholder="#" />
</td>
</tr>
<tr>
<td class="close_top">
&nbsp;<br />
<input type="submit" name="back" id="back" value="#!string!striker_0098!#" class="button">
</td>
<td class="close_top" style="text-align: right;" colspan="#!variable!span_count!#">
&nbsp;<br />
<input type="submit" name="save" id="save" value="#!string!striker_0067!#" class="button">
</td>
<input type="hidden" name="fence_agent" id="fence_agent" value="#!data!cgi::fence_agent::value!#">
<input type="hidden" name="fence_count" id="fence_count" value="#!data!cgi::fence_count::value!#">
<input type="hidden" name="add" id="add" value="true">
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="fences">
<input type="hidden" name="confirm" id="confirm" value="true">
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
</table>
<!-- end new-manifest-step1 -->
<!-- start fence-agent-configuration -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
@ -102,7 +195,7 @@
</tr>
<tr>
<td colspan="2">
<form name="conce_configuration" action="" method="post">
<form name="fence_configuration" action="" method="post">
<table class="centered">
#!variable!options!#
<tr>
@ -127,6 +220,208 @@
</table>
<!-- end fence-agent-configuration -->
<!-- start ups-option-menu -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
#!variable!device!# &nbsp;
</td>
<td class="column_row_centered_input">
<input type="text" name="#!variable!name_key!#" id="#!variable!name_key!#" placeholder="#!string!striker_0016!#" value="#!variable!name!#" />
</td>
<td class="column_row_centered_input">
<input type="text" name="#!variable!ip_address_key!#" id="#!variable!ip_address_key!#" placeholder="#!string!striker_0024!#" value="#!variable!ip_address!#" />
</td>
<td>
#!variable!agent!#
</td>
</tr>
<input type="hidden" name="#!variable!fence_uuid_key!#" id="#!variable!fence_uuid_key!#" value="#!variable!fence_uuid!#" />
<!-- end ups-option-menu -->
<!-- start ups-option-menu-confirm -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
#!variable!device!# &nbsp;
</td>
<td class="column_row_centered_input">
&nbsp; #!variable!name!# &nbsp;
<input type="hidden" name="#!variable!name_key!#" id="#!variable!name_key!#" value="#!variable!name!#" />
</td>
<td class="column_row_centered_input">
&nbsp; #!variable!ip_address!# &nbsp;
<input type="hidden" name="#!variable!ip_address_key!#" id="#!variable!ip_address_key!#" value="#!variable!ip_address!#" />
</td>
<td>
&nbsp; #!variable!say_agent!#
<input type="hidden" name="#!variable!agent_key!#" id="#!variable!agent_key!#" value="#!variable!agent!#" />
</td>
</tr>
<input type="hidden" name="#!variable!fence_uuid_key!#" id="#!variable!fence_uuid_key!#" value="#!variable!fence_uuid!#" />
<!-- end ups-option-menu-confirm -->
<!-- start ups-configuration -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<img src="#!data!skin::url!#/images/ups.png" class="top_icon" >
</td>
<td class="title">
#!string!striker_0240!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td class="description">
#!variable!description!#
</td>
</tr>
<tr>
<td colspan="2">
<form name="ups_configuration" action="" method="post">
<table class="centered">
<tr>
<td class="column_header">
&nbsp;
</td>
<td class="column_header">
<!-- Name -->
#!string!header_0026!#
</td>
<td class="column_header">
<!-- IP Address -->
#!string!header_0025!#
</td>
<td class="column_header">
<!-- Brand (agent) -->
#!string!header_0027!#
</td>
</tr>
#!variable!upses!#
<tr>
<td colspan="4" class="button_cell">
<input type="submit" name="save" id="save" value="#!string!striker_0067!#" class="button">
<input type="hidden" name="ups_agent" id="ups_agent" value="#!data!cgi::ups_agent::value!#">
<input type="hidden" name="ups_count" id="ups_count" value="#!data!cgi::ups_count::value!#">
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="upses">
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<table class="centered">
<tr style="border: 1px dotted #7f7f7f;">
<td class="column_header">
<!-- Name -->
#!string!header_0026!# &nbsp;
</td>
<td>
#!string!striker_0235!#
</td>
</tr>
<tr style="border: 1px dotted #7f7f7f;">
<td class="column_header">
<!-- IP Address -->
#!string!header_0025!# &nbsp;
</td>
<td>
#!string!striker_0241!#
</td>
</tr>
<tr style="border: 1px dotted #7f7f7f;">
<td class="column_header">
<!-- Brand (agent) -->
#!string!header_0027!# &nbsp;
</td>
<td>
#!string!striker_0242!#
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- end ups-configuration -->
<!-- start ups-configuration-confirm -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<img src="#!data!skin::url!#/images/ups.png" class="top_icon" >
</td>
<td class="title">
#!string!striker_0243!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td class="description">
#!variable!confirm!#
</td>
</tr>
<tr>
<td colspan="2">
<form name="ups_configuration" action="" method="post">
<table class="centered">
<tr>
<td class="column_header">
&nbsp;
</td>
<td class="column_header">
<!-- Name -->
#!string!header_0026!#
</td>
<td class="column_header">
<!-- IP Address -->
#!string!header_0025!#
</td>
<td class="column_header">
<!-- Brand (agent) -->
#!string!header_0027!#
</td>
</tr>
#!variable!upses!#
<tr>
<td colspan="4" class="button_cell">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#" class="button">
<input type="hidden" name="ups_count" id="ups_count" value="#!data!cgi::ups_count::value!#">
<input type="hidden" name="save" id="save" value="true">
<input type="hidden" name="confirm" id="confirm" value="true">
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="upses">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<!-- end ups-configuration-confirm -->
<!-- start fence-agent-row -->
<tr>
#!variable!columns!#
@ -146,6 +441,19 @@
</td>
<!-- end fence-agent-column-hidden-value -->
<!-- start ups-column -->
<td class="column_row_value_centered_border">
<span class="#!variable!class!#">#!variable!value!#</span>
</td>
<!-- end ups-column -->
<!-- start ups-column-hidden-value -->
<td class="column_row_value_centered_border">
<span class="#!variable!class!#">#!variable!say_value!#</span>
<input type="hidden" name="#!variable!name!#" id="#!variable!name!#" value="#!variable!value!#" />
</td>
<!-- end ups-column-hidden-value -->
<!-- start fence-agent-confirm -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
@ -179,7 +487,7 @@
</tr>
<tr>
<td colspan="2">
<form name="conce_configuration" action="" method="post">
<form name="fence_configuration" action="" method="post">
<table class="centered">
#!variable!table!#
<tr>
@ -210,6 +518,71 @@
</table>
<!-- end fence-agent-confirm -->
<!-- start ups-delete-confirm -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<img src="#!data!skin::url!#/images/ups.png" class="top_icon" >
</td>
<td class="title">
#!string!striker_0225!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<form name="ups_configuration" action="" method="post">
<table class="centered">
<tr style="border: 1px dotted #7f7f7f;">
<td colspan="2" class="column_header">
#!string!header_0024!#
</td>
</tr>
<tr style="border: 1px dotted #7f7f7f;">
<td colspan="2" class="fixed_width">
#!variable!say_device!#
<input type="hidden" name="delete_ups_uuid" id="delete_ups_uuid" value="#!data!cgi::delete_ups_uuid::value!#">
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="close_top">
&nbsp;<br />
<input type="submit" name="back" id="back" value="#!string!striker_0098!#" class="button">
</td>
<td class="close_top" style="text-align: right;">
&nbsp;<br />
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#" class="button">
</td>
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="upses">
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
</table>
<!-- end ups-delete-confirm -->
<!-- start fence-agent-delete-confirm -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
@ -233,9 +606,7 @@
</tr>
<tr>
<td colspan="2">
#!variable!confirm_string!#
</td>
</tr>
<tr>
@ -245,7 +616,7 @@
</tr>
<tr>
<td colspan="2">
<form name="conce_configuration" action="" method="post">
<form name="fence_configuration" action="" method="post">
<table class="centered">
<tr style="border: 1px dotted #7f7f7f;">
<td colspan="2" class="column_header">
@ -348,6 +719,11 @@
#!string!striker_0224!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;
@ -387,6 +763,59 @@
</tr>
<!-- end existing-fence-devices -->
<!-- start existing-upses -->
<tr>
<td>
&nbsp;
</td>
<td>
#!string!striker_0236!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td>
<table>
<div id="existing_ups_devices">
<tr style="border: 1px dotted #7f7f7f;">
<!-- Device name -->
<td class="column_header">
#!string!header_0003!#:
</td>
<td>
&nbsp;
</td>
<!-- Delete -->
<td class="column_header">
#!string!header_0022!#
</td>
<td>
&nbsp;
</td>
<!-- agent and arguments -->
<td class="column_header">
#!string!header_0025!#
</td>
</tr>
#!variable!upses!#
</div>
</table>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<!-- end existing-upses -->
<!-- start existing-fence-device-entry -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
@ -407,6 +836,26 @@
</tr>
<!-- end existing-fence-device-entry -->
<!-- start existing-ups-entry -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
<a href="?anvil=true&task=upses&ups_agent=#!variable!ups_agent!#&ups_count=1&ups_uuid_1=#!variable!ups_uuid!#" class="fixed_link_highlight">#!variable!name!#</a>
</td>
<td>
&nbsp;
</td>
<td style="text-align: center;">
<a href="?anvil=true&task=upses&delete_ups_uuid=#!variable!ups_uuid!#" class="fixed_link_highlight"><img src="#!data!skin::url!#/images/delete.png" alt="#!string!striker_0068!#" style="height: .8em;"></a>
</td>
<td>
&nbsp;
</td>
<td class="fixed_width">
#!variable!ip_address!#
</td>
</tr>
<!-- end existing-ups-entry -->
<!-- start fence-agent-menu -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
@ -525,6 +974,123 @@
</table>
<!-- end fence-agent-menu -->
<!-- start ups-agent-menu -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<img src="#!data!skin::url!#/images/ups.png" class="top_icon" >
</td>
<td class="title">
#!string!striker_0231!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td class="description">
#!string!striker_0237!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
#!variable!existing_upses!#
<tr>
<td>
&nbsp;
</td>
<td>
#!string!striker_0231!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td>
<table>
<div id="new_upses">
<form name="new_upses" action="" method="post">
<tr>
<td>
#!string!striker_0070!#:
</td>
<td>
&nbsp;
</td>
<td>
#!variable!ups_select!#
</td>
</tr>
<tr>
<td>
#!string!striker_0212!#:
</td>
<td>
&nbsp;
</td>
<td>
#!variable!ups_count!#
</td>
</tr>
<tr>
<td colspan="3">
&nbsp;
</td>
</tr>
<tr>
<td colspan="3" class="no_border_right">
<input type="submit" name="add" id="add" class="button" value="#!string!striker_0070!#">
<input type="hidden" name="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="upses">
</td>
</tr>
</form>
</div>
</table>
</td>
</tr>
<div id="ups_agent_list">
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
#!string!striker_0238!#
</td>
</tr>
<tr>
<td colspan="2">
<table>
#!variable!descriptions!#
</table>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
</div>
</table>
<!-- end ups-agent-menu -->
<!-- start fence-agent-description -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
@ -536,6 +1102,17 @@
</tr>
<!-- end fence-agent-description -->
<!-- start ups-agent-description -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
<span class="column_row_value_fixed">#!variable!name!#</a> &nbsp;
</td>
<td>
&nbsp; #!variable!description!#
</td>
</tr>
<!-- end ups-agent-description -->
<!-- start existing-manifest-entry -->
<tr>
<td>

@ -387,10 +387,10 @@
<td class="column_row_name">
#!string!header_0003!#
</td>
<td id="network_link_state" data-up="#!string!js_0001!#" data-down="#!string!js_0002!#" class="column_row_name">
<td id="network_link_state" data-up="#!string!unit_0029!#" data-down="#!string!unit_0030!#" class="column_row_name">
#!string!header_0004!#
</td>
<td id="network_link_speed" data-mbps="#!string!js_0003!#" class="column_row_name">
<td id="network_link_speed" data-mbps="#!string!unit_0031!#" class="column_row_name">
#!string!header_0005!#
</td>
<td class="column_row_name">

@ -76,3 +76,6 @@ instructions by Prettycons from the Noun Project (https://thenounproject.com/ter
Fence by P Thanga Vignesh from the Noun Project (https://thenounproject.com/term/fence/1010653/)
- fence.png
uninterruptible power supply by Denis Shumaylov from the Noun Project (https://thenounproject.com/term/uninterruptible-power-supply/1201263/)
- ups.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -415,6 +415,12 @@ td.column_row_value_fixed_centered {
font-size: 0.9em;
}
td.column_row_centered_input {
text-align: center;
vertical-align: middle;
padding: 0.2em;
}
td.column_subrow_name {
text-align: right;
vertical-align: top;

@ -233,7 +233,7 @@
<script type="text/javascript" src="/skins/alteeve/jobs.js"></script>
<tr>
<td>
<input type="hidden" name="status_waiting" id="status_waiting" value="#!string!js_0004!#">
<input type="hidden" name="status_waiting" id="status_waiting" value="#!string!unit_0032!#">
<span name="jobs-title" id="jobs-title" class="config_header2">#!string!header_0011!#</span><br />
<span name="jobs-message" id="jobs-message" class="config_header3">#!string!striker_0096!#</span>
<br />
@ -355,7 +355,7 @@
<script type="text/javascript" src="/skins/alteeve/jobs.js"></script>
<tr>
<td>
<input type="hidden" name="status_waiting" id="status_waiting" value="#!string!js_0004!#">
<input type="hidden" name="status_waiting" id="status_waiting" value="#!string!unit_0032!#">
<span name="jobs-title" id="jobs-title" class="config_header2">#!string!header_0011!#</span><br />
<span name="jobs-message" id="jobs-message" class="config_header3">#!string!striker_0096!#</span>
<br />

@ -43,6 +43,7 @@ Requires: perl-Capture-Tiny
Requires: perl-Data-Dumper
Requires: perl-DBD-Pg
Requires: perl-DBI
Requires: perl-Data-Validate-Domain
Requires: perl-Digest-SHA
Requires: perl-File-MimeInfo
Requires: perl-HTML-FromText

@ -1562,6 +1562,54 @@ CREATE TRIGGER trigger_fences
FOR EACH ROW EXECUTE PROCEDURE history_fences();
-- This stores the information about UPSes powering devices.
CREATE TABLE upses (
ups_uuid uuid not null primary key,
ups_name text not null, -- This is the name of the ups device. Usually this is the host name of the device (ie: xx-pdu01.example.com)
ups_agent text not null, -- This is the ups agent name used to communicate with the device. ie: 'ups_apc_ups', 'ups_virsh', etc.
ups_ip_address text not null, -- This is the IP address of the UPS
modified_date timestamp with time zone not null
);
ALTER TABLE upses OWNER TO admin;
CREATE TABLE history.upses (
history_id bigserial,
ups_uuid uuid,
ups_name text,
ups_agent text,
ups_ip_address text,
modified_date timestamp with time zone
);
ALTER TABLE history.upses OWNER TO admin;
CREATE FUNCTION history_upses() RETURNS trigger
AS $$
DECLARE
history_upses RECORD;
BEGIN
SELECT INTO history_upses * FROM upses WHERE ups_uuid = new.ups_uuid;
INSERT INTO history.upses
(ups_uuid,
ups_name,
ups_agent,
ups_ip_address,
modified_date)
VALUES
(history_upses.ups_uuid,
history_upses.ups_name,
history_upses.ups_agent,
history_upses.ups_ip_address,
history_upses.modified_date);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
ALTER FUNCTION history_upses() OWNER TO admin;
CREATE TRIGGER trigger_upses
AFTER INSERT OR UPDATE ON upses
FOR EACH ROW EXECUTE PROCEDURE history_upses();
-- ------------------------------------------------------------------------------------------------------- --
-- These are special tables with no history or tracking UUIDs that simply record transient information. --

File diff suppressed because it is too large Load Diff

@ -3,12 +3,7 @@
use strict;
use warnings;
use Anvil::Tools;
use XML::Simple;
use JSON;
use Math::BigInt;
use Data::Dumper;
use Net::Netmask;
#use Anvil::Tools;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@ -20,90 +15,54 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1;
print "Starting test.\n";
my $anvil = Anvil::Tools->new({debug => 3});
$anvil->Log->secure({set => 1});
$anvil->Log->level({set => 2});
# 2.75 = 69.85 - use up to 55 mm
# 2.25 = 57.15 - use up to 45 mm
# 1.75 = 44.45 - use up to 30 mm
# 1.25 = 31.75 - use up to 20 mm
#print "Connecting to the database(s);\b";
$anvil->Database->connect({debug => 3});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
#print "DB Connections: [".$anvil->data->{sys}{database}{connections}."]\n";
#$anvil->Network->load_interfces({debug => 2});
#$anvil->System->generate_state_json({debug => 2});
my $one_two_five = [];
my $one_seven_five = [];
my $two_two_five = [];
my $two_seven_five = [];
#$anvil->Words->language_list();
#foreach my $iso (sort {$a cmp $b} keys %{$anvil->data->{sys}{languages}})
#{
# print "iso: [".$iso."] -> [".$anvil->data->{sys}{languages}{$iso}."]\n";
#}
my $data = "26,31,25,22,24,23,,
,36,37,34,30,38,35,,
,43,43,42,34,39,35,,
,47,47,48,40,33,31,23,17,
,47,47,41,37,35,22,19,8,11
,42,42,46,50,39,27,21,5,10
,42,40,43,49,35,33,30,26,
,39,39,36,39,31,28,25,25,
,36,35,32,29,19,20,15,15,
,33,31,31,15,21,23,17,11,
,31,33,30,23,26,21,20,14,
,23,42,26,17,12,20,16,20";
$anvil->Striker->get_fence_data({debug => 3});
my $fence_agent = "fence_apc_snmp";
print "Fence agent: [".$fence_agent."]\n";
foreach my $name (sort {$a cmp $b} keys %{$anvil->data->{fences}{$fence_agent}{parameters}})
foreach my $line (split/\n/, $data)
{
foreach my $depth (split/,/, $line)
{
next if $anvil->data->{fences}{$fence_agent}{parameters}{$name}{replacement};
next if $anvil->data->{fences}{$fence_agent}{parameters}{$name}{deprecated};
my $unique = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{unique};
my $required = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{required};
my $description = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{description};
my $type = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{content_type};
my $default = exists $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} ? $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} : "";
print "- name: [$name], default: [".$default."]\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
name => $name,
unique => $unique,
required => $required,
description => $description,
type => $type,
'default' => $default,
}});
next if not $depth;
if ($depth >= 45) { push @{$two_seven_five}, $depth; }
elsif ($depth >= 30) { push @{$two_two_five}, $depth; }
elsif ($depth >= 20) { push @{$one_seven_five}, $depth; }
else { push @{$one_two_five}, $depth; }
}
}
# foreach my $fence_agent (sort {$a cmp $b} keys %{$anvil->data->{fences}})
# {
# # We skip fence_ipmilan, that's handled in the host.
# next if $fence_agent eq "fence_ipmilan";
#
# my $agent_description = $anvil->data->{fences}{$fence_agent}{description};
# print "Agent: [".$fence_agent."]\n";
# print "==========\n";
# print $agent_description."\n";
# print "==========\n";
# foreach my $name (sort {$a cmp $b} keys %{$anvil->data->{fences}{$fence_agent}{parameters}})
# {
# next if $anvil->data->{fences}{$fence_agent}{parameters}{$name}{replacement};
# next if $anvil->data->{fences}{$fence_agent}{parameters}{$name}{deprecated};
# my $unique = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{unique};
# my $required = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{required};
# my $description = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{description};
# my $switches = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{switches};
# my $type = $anvil->data->{fences}{$fence_agent}{parameters}{$name}{content_type};
# my $star = $required ? "*" : "";
# my $default = exists $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} ? $anvil->data->{fences}{$fence_agent}{parameters}{$name}{'default'} : "";
# print "- [".$name."]".$star.": Type: [".$type."], default: [".$default."], switches: [".$switches."]: [".$description."]\n";
# print " - Unique!\n" if $unique;
#
# if ($type eq "select")
# {
# # Build the select box
# my $options = "";
# foreach my $option (sort @{$anvil->data->{fences}{$fence_agent}{parameters}{$name}{options}})
# {
# if (($default) && ($option eq $default))
# {
# $options .= " - [".$option."]*\n";
# }
# else
# {
# $options .= " - [".$option."]\n";
# }
# }
# print $options;
# }
# }
#
#
# }
print "2.75\": [".@{$two_seven_five}."]\n";
print "2.25\": [".@{$two_two_five}."]\n";
print "1.75\": [".@{$one_seven_five}."]\n";
print "1.25\": [".@{$one_two_five}."]\n";
print "Total: [".(@{$two_seven_five} + @{$two_two_five} + @{$one_seven_five} + @{$one_two_five})."]\n";
# my $anvil = Anvil::Tools->new({debug => 3});
# $anvil->Log->secure({set => 1});
# $anvil->Log->level({set => 2});
#print "Connecting to the database(s);\b";
#$anvil->Database->connect({debug => 3});
#$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
#print "DB Connections: [".$anvil->data->{sys}{database}{connections}."]\n";
#$anvil->Striker->get_ups_data({debug => 2});

Loading…
Cancel
Save