* Finished the menus to save a new Install Manifest and got the create page showing the existing manifests.

* Updated Database->insert_or_update_manifests() so that not passing in 'manifest_last_ran' is OK.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 97bcab86d6
commit 099bc1401a
  1. 33
      Anvil/Tools/Database.pm
  2. 36
      Anvil/Tools/Striker.pm
  3. 28
      cgi-bin/striker
  4. 52
      html/skins/alteeve/anvil.html
  5. BIN
      html/skins/alteeve/images/run.png
  6. 3
      html/skins/alteeve/images/sources.txt
  7. 2
      share/words.xml
  8. 70
      tools/test.pl

@ -5545,9 +5545,9 @@ When set, this UUID is used to update an existing record. When not passed, the C
This is the name of the manifest. Generally, this is the name of the Anvil! itself. It can be set to something more useful to the user, however. This is the name of the manifest. Generally, this is the name of the Anvil! itself. It can be set to something more useful to the user, however.
=head3 manifest_last_ran (required) =head3 manifest_last_ran (optional, default 0)
This is the unix time when the manifest was last used to (re)build an Anvil! system. Set this to C<< 0 >> if the manifest hasn't been used yet. This is the unix time when the manifest was last used to (re)build an Anvil! system. If not passed, the value is not changed. If the manifest is new, this is set to C<< 0 >>.
=head3 manifest_xml (required) =head3 manifest_xml (required)
@ -5586,7 +5586,6 @@ sub insert_or_update_manifests
manifest_note => $manifest_note, manifest_note => $manifest_note,
}}); }});
# INSERT, but make sure we have enough data first. # INSERT, but make sure we have enough data first.
if (not $delete) if (not $delete)
{ {
@ -5609,7 +5608,8 @@ sub insert_or_update_manifests
# devices can share the MAC with the real interface. # devices can share the MAC with the real interface.
my $query = " my $query = "
SELECT SELECT
manifest_uuid manifest_uuid,
manifest_last_ran
FROM FROM
manifests manifests
WHERE WHERE
@ -5617,9 +5617,28 @@ WHERE
;"; ;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$manifest_uuid = $anvil->Database->query({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__})->[0]->[0]; my $results = $anvil->Database->query({uuid => $uuid, query => $query, uuid => $uuid, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
$manifest_uuid = "" if not defined $manifest_uuid; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_uuid => $manifest_uuid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
if ($count)
{
# If we weren't passed a 'manifest_last_ran', load the old value here.
$manifest_uuid = $results->[0]->[0];
$manifest_last_ran = $results->[0]->[1] if $manifest_last_ran eq "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
manifest_uuid => $manifest_uuid,
manifest_last_ran => $manifest_last_ran,
}});
}
elsif ($manifest_last_ran eq "")
{
# This is a new manifest and 'manifest_last_ran' wasn't passed, so set it to 0.
$manifest_last_ran = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_last_ran => $manifest_last_ran }});
}
} }
if ($delete) if ($delete)

@ -96,7 +96,7 @@ sub generate_manifest
$anvil->Database->get_upses({debug => $debug}); $anvil->Database->get_upses({debug => $debug});
$anvil->Database->get_fences({debug => $debug}); $anvil->Database->get_fences({debug => $debug});
my $manifest_uuid = $anvil->data->{cgi}{manifest_uuid}{value}; my $manifest_uuid = $anvil->data->{cgi}{manifest_uuid}{value} eq "new" ? "" : $anvil->data->{cgi}{manifest_uuid}{value};
my $padded_sequence = $anvil->data->{cgi}{sequence}{value}; my $padded_sequence = $anvil->data->{cgi}{sequence}{value};
if (length($padded_sequence) == 1) if (length($padded_sequence) == 1)
{ {
@ -179,30 +179,8 @@ sub generate_manifest
$manifest_xml .= ' </fences> $manifest_xml .= ' </fences>
<machines> <machines>
'; ';
=cut
2020/05/13 11:59:14:Get.pm:394; cgi::dr1_bcn1_network::value ... : [10.201.14.3]
2020/05/13 11:59:14:Get.pm:394; cgi::dr1_ifn1_network::value ... : [10.255.14.3]
2020/05/13 11:59:14:Get.pm:394; cgi::dr1_ifn2_network::value ... : [192.168.122.16]
2020/05/13 11:59:14:Get.pm:394; cgi::dr1_sn1_network::value .... : [10.101.14.3]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_bcn1_network::value . : [10.201.14.1]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_ifn1_network::value . : [10.255.14.1]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_ifn2_network::value . : [192.168.122.14]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_sn1_network::value .. : [10.101.14.1]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_bcn1_network::value . : [10.201.14.2]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_ifn1_network::value . : [10.255.14.2]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_ifn2_network::value . : [192.168.122.15]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_ipmi_ip::value ...... : [10.201.15.2]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_sn1_network::value .. : [10.101.14.2]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_fence_el8-pdu01::value: [1]
2020/05/13 11:59:14:Get.pm:394; cgi::node1_fence_el8-pdu02::value: [1]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_fence_el8-pdu01::value: [2]
2020/05/13 11:59:14:Get.pm:394; cgi::node2_fence_el8-pdu02::value: [2]
2020/05/13 11:59:14:Get.pm:394; cgi::manifest_uuid::value ...... : [new] # Now record the info about the machines.
=cut
foreach my $machine (sort {$a cmp $b} keys %{$machines}) foreach my $machine (sort {$a cmp $b} keys %{$machines})
{ {
my $host_name = $node1_name; my $host_name = $node1_name;
@ -241,7 +219,15 @@ sub generate_manifest
'; ';
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_xml => $manifest_xml }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { manifest_xml => $manifest_xml }});
return($manifest_uuid); # Now save the manifest!
($manifest_uuid) = $anvil->Database->insert_or_update_manifests({
debug => $debug,
manifest_uuid => $manifest_uuid,
manifest_name => $anvil_name,
manifest_xml => $manifest_xml,
});
return($manifest_uuid, $anvil_name);
} }
=head2 get_fence_data =head2 get_fence_data

@ -1599,8 +1599,26 @@ sub handle_manifest
else else
{ {
# Save the manifest! # Save the manifest!
$anvil->data->{cgi}{step}{value} = 3; my ($manifest_uuid, $manifest_name) = $anvil->Striker->generate_manifest({debug => 2});
my ($manifest_uuid) = $anvil->Striker->generate_manifest({debug => 2}); if ($manifest_uuid)
{
# Success!
my $message = $anvil->Words->string({key => "ok_0009", variables => { name => $manifest_name }});
$anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "form::ok_message" => $anvil->data->{form}{ok_message} }});
# Go back to the main page.
process_create($anvil);
return(0);
}
else
{
# Something went wrong, go back to the third page
$anvil->data->{cgi}{step}{value} = 3;
my $message = $anvil->Words->string({key => "warning_0041"});
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "form::error_massage" => $anvil->data->{form}{error_massage} }});
}
} }
} }
} }
@ -2677,7 +2695,7 @@ ORDER BY
manifest_xml => $manifest_xml, manifest_xml => $manifest_xml,
manifest_note => $manifest_note, manifest_note => $manifest_note,
}}); }});
$manifest_template .= $anvil->Template->get({file => "anvil.html", name => "existing-manifest-entry", variables => { $manifest_template .= $anvil->Template->get({file => "anvil.html", name => "create-menu-existing-manifest-entry", variables => {
manifest_uuid => $manifest_uuid, manifest_uuid => $manifest_uuid,
manifest_name => $manifest_name, manifest_name => $manifest_name,
}}); }});
@ -2811,8 +2829,8 @@ sub process_upses
if ($ups_uuid) if ($ups_uuid)
{ {
# Deleted successfully # Deleted successfully
my $message = $anvil->Words->string({key => "ok_0008", variables => { name => $ups_name }}); my $message = $anvil->Words->string({key => "ok_0008", variables => { name => $ups_name }});
$anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $message }}); $anvil->data->{form}{ok_message} = $anvil->Template->get({file => "main.html", name => "ok_message", variables => { ok_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "form::ok_message" => $anvil->data->{form}{ok_message} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "form::ok_message" => $anvil->data->{form}{ok_message} }});
} }
else else

@ -49,23 +49,50 @@
<td class="main_option_icon"> <td class="main_option_icon">
&nbsp; &nbsp;
</td> </td>
<td class="main_option"> <td>
#!string!striker_0205!# #!string!striker_0205!#
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="main_option_icon"> <td>
&nbsp; &nbsp;
</td> </td>
<td class="main_option"> <td class="main_option" col>
<table> <table>
#!variable!existing_manifests!# <div id="existing_manifests">
<tr style="border: 1px dotted #7f7f7f;">
<td class="column_header">
#!string!striker_0207!#
</td>
<td class="column_header">
#!string!striker_0206!#
</td>
<td class="column_header">
#!string!header_0022!#
</td>
</tr>
#!variable!existing_manifests!#
</div>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
<!-- end create-menu --> <!-- end create-menu -->
<!-- start create-menu-existing-manifest-entry -->
<tr style="border: 1px dotted #7f7f7f;">
<td>
<a href="?anvil=true&task=manifest&edit=true&manifest_uuid=#!variable!manifest_uuid!#" class="fixed_link_highlight">#!variable!manifest_name!#</a> &nbsp;
</td>
<td style="text-align: center;">
<a href="?anvil=true&task=manifest&run=true&manifest_uuid=#!variable!manifest_uuid!#"><img src="#!data!skin::url!#/images/run.png" alt="#!string!striker_0206!#" style="height: .8em;"></a> &nbsp;
</td>
<td style="text-align: center;">
<a href="?anvil=true&task=manifest&delete=true&manifest_uuid=#!variable!manifest_uuid!#"><img src="#!data!skin::url!#/images/delete.png" alt="#!string!striker_0068!#" style="height: .8em;"></a>
</td>
</tr>
<!-- end create-menu-existing-manifest-entry -->
<!-- start manifest-step1 --> <!-- start manifest-step1 -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script> <script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
@ -1702,23 +1729,6 @@
</tr> </tr>
<!-- end ups-agent-description --> <!-- end ups-agent-description -->
<!-- start existing-manifest-entry -->
<tr>
<td>
<a href="?anvil=true&task=manifest&run=true&manifest_uuid=#!variable!manifest_uuid!#">#!string!striker_0206!#</a>
</td>
<td>
#!variable!manifest_name!#
</td>
<td>
<a href="?anvil=true&task=manifest&edit=true&manifest_uuid=#!variable!manifest_uuid!#">#!string!striker_0207!#</a>
</td>
<td>
<a href="?anvil=true&task=manifest&delete=true&manifest_uuid=#!variable!manifest_uuid!#"><img src="#!data!skin::url!#/images/delete.png" alt="#!string!striker_0068!#" style="height: .8em;"></a>
</td>
</tr>
<!-- end existing-manifest-entry -->
<!-- start main-menu --> <!-- start main-menu -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script> <script type="text/javascript" src="/skins/alteeve/anvil.js"></script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@ -79,3 +79,6 @@ Fence by P Thanga Vignesh from the Noun Project (https://thenounproject.com/term
uninterruptible power supply by Denis Shumaylov from the Noun Project (https://thenounproject.com/term/uninterruptible-power-supply/1201263/) uninterruptible power supply by Denis Shumaylov from the Noun Project (https://thenounproject.com/term/uninterruptible-power-supply/1201263/)
- ups.png - ups.png
operation by Adrien Coquet from the Noun Project (https://thenounproject.com/term/operation/2998606/)
- run.png

@ -1101,6 +1101,7 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t
<key name="ok_0006">The fence device: [#!variable!name!#] has been successfully deleted!</key> <key name="ok_0006">The fence device: [#!variable!name!#] has been successfully deleted!</key>
<key name="ok_0007">The UPS: [#!variable!name!#] has been successfully saved!</key> <key name="ok_0007">The UPS: [#!variable!name!#] has been successfully saved!</key>
<key name="ok_0008">The UPS: [#!variable!name!#] has been successfully deleted!</key> <key name="ok_0008">The UPS: [#!variable!name!#] has been successfully deleted!</key>
<key name="ok_0009">The install manifest: [#!variable!name!#] has been successfully saved!</key>
<!-- String prefixes --> <!-- String prefixes -->
<key name="prefix_0001">[ Error ] - </key> <key name="prefix_0001">[ Error ] - </key>
@ -1547,6 +1548,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="warning_0038">[ Warning ] - The UPS: [#!variable!name!#] appears to have not been saved.</key> <key name="warning_0038">[ Warning ] - The UPS: [#!variable!name!#] appears to have not been saved.</key>
<key name="warning_0039">[ Warning ] - There's a problem with the form.</key> <key name="warning_0039">[ Warning ] - There's a problem with the form.</key>
<key name="warning_0040">[ Warning ] - The UPS: [#!variable!name!#] with the UUID: [#!variable!uuid!#] was NOT deleted. The reason may be in the: [#!data!path::log::main!#] log file on this host.</key> <key name="warning_0040">[ Warning ] - The UPS: [#!variable!name!#] with the UUID: [#!variable!uuid!#] was NOT deleted. The reason may be in the: [#!data!path::log::main!#] log file on this host.</key>
<key name="warning_0041">[ Warning ] - There was a problem saving the install manifest. The reason may be in the: [#!data!path::log::main!#] log file on this host.</key>
</language> </language>
<!-- 日本語 --> <!-- 日本語 -->

@ -3,7 +3,8 @@
use strict; use strict;
use warnings; use warnings;
#use Anvil::Tools; use Anvil::Tools;
use Data::Dumper;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0]; my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0]; my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@ -15,58 +16,27 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
# 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;
foreach my $i (1..6) my $anvil = Anvil::Tools->new({debug => 2});
{ $anvil->Log->secure({set => 1});
my $out = 8 + (2 * $i); $anvil->Log->level({set => 2});
print "$i: [$out]\n";
}
my $parsed_xml = "";
my $xml_body = $anvil->Storage->read_file({file => "/root/test.xml"});
# # 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
#
# my $one_two_five = [];
# my $one_seven_five = [];
# my $two_two_five = [];
# my $two_seven_five = [];
#
# 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";
#
#
# foreach my $line (split/\n/, $data)
# {
# foreach my $depth (split/,/, $line)
# {
# 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; }
# }
# }
#
# 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}); my $xml = XML::Simple->new();
# $anvil->Log->secure({set => 1}); eval { $parsed_xml = $xml->XMLin($xml_body, KeyAttr => { key => 'name' }, ForceArray => []) };
# $anvil->Log->level({set => 2}); if ($@)
{
chomp $@;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0111", variables => {
xml_body => $xml_body,
eval_error => $@,
}});
return(1);
}
print Dumper $parsed_xml;
#print "Connecting to the database(s);\b"; #print "Connecting to the database(s);\b";
#$anvil->Database->connect({debug => 3}); #$anvil->Database->connect({debug => 3});

Loading…
Cancel
Save