* Continued work on creating Install Manifests. Got the frame of step 1 done.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent e66bc32693
commit 1351889b4d
  1. 237
      cgi-bin/striker
  2. 42
      html/skins/alteeve/anvil.html
  3. 4
      share/words.xml

@ -1501,6 +1501,11 @@ sub process_anvil_menu
{ {
process_prep_network($anvil); process_prep_network($anvil);
} }
elsif ($anvil->data->{cgi}{task}{value} eq "create")
{
# This handles the main "create an anvil" page.
process_create($anvil);
}
elsif ($anvil->data->{cgi}{task}{value} eq "fences") elsif ($anvil->data->{cgi}{task}{value} eq "fences")
{ {
process_fences($anvil); process_fences($anvil);
@ -1509,11 +1514,7 @@ sub process_anvil_menu
{ {
process_upses($anvil); process_upses($anvil);
} }
elsif ($anvil->data->{cgi}{task}{value} eq "create") elsif ($anvil->data->{cgi}{task}{value} eq "manifests")
{
process_manifests($anvil);
}
elsif ($anvil->data->{cgi}{task}{value} eq "manifest")
{ {
process_manifests($anvil); process_manifests($anvil);
} }
@ -1528,42 +1529,117 @@ sub process_anvil_menu
return(0); return(0);
} }
# This handles creating an Install Manifest. # This handles creating or editing an Install Manifest.
sub handle_new_manifest sub handle_manifest
{ {
my ($anvil) = @_; my ($anvil) = @_;
$anvil->data->{cgi}{prefix}{value} = "" if not defined $anvil->data->{cgi}{prefix}{value};
$anvil->data->{cgi}{sequence}{value} = "" if not defined $anvil->data->{cgi}{sequence}{value};
$anvil->data->{cgi}{ifn_count}{value} = "" if not defined $anvil->data->{cgi}{ifn_count}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"cgi::prefix::value" => $anvil->data->{cgi}{prefix}{value},
"cgi::sequence::value" => $anvil->data->{cgi}{sequence}{value},
"cgi::ifn_count::value" => $anvil->data->{cgi}{ifn_count}{value},
}});
# Step 1 is to ask for the sequence number, prefix, and the number of IFNs (and later, BCNs) # Step 1 is to ask for the sequence number, prefix, and the number of IFNs (and later, BCNs)
my $prefix = "";
my $sequence = 1;
my $ifn_count = 1;
if (($anvil->data->{cgi}{manifest_uuid}{value} eq "new") && ($anvil->data->{cgi}{step}{value} eq "1"))
{
# Pre-load values
if ($anvil->data->{cgi}{prefix}{value})
{
$prefix = $anvil->data->{cgi}{prefix}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { prefix => $prefix }});
}
else
{
$prefix = $anvil->_short_host_name() =~ /-/ ? $anvil->_short_host_name() : "xx";
$prefix =~ s/-.*$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { prefix => $prefix }});
}
if ($anvil->data->{cgi}{sequence}{value})
{
$sequence = $anvil->data->{cgi}{sequence}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sequence => $sequence }});
}
else
{
# Count the number of existing manifests! systems with the default prefix to guess the next sequence.
my $query = "SELECT manifest_name FROM manifests WHERE manifest_name LIKE ".$anvil->Database->quote($prefix."-%")." ORDER BY manifest_name ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
results => $results,
count => $count,
}});
if ($count)
{
# Yup, key has changed.
foreach my $row (@{$results})
{
my $manifest_name = $row->[0];
my $this_sequence = ($manifest_name =~ /-(\d+)$/)[0];
$this_sequence =~ s/^0//g;
$this_sequence = 0 if not $this_sequence;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
manifest_name => $manifest_name,
this_sequence => $this_sequence,
}});
if ($this_sequence >= $sequence)
{
$sequence = $this_sequence + 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sequence => $sequence }});
}
}
}
}
if ($anvil->data->{cgi}{ifn_count}{value})
{
$ifn_count = $anvil->data->{cgi}{ifn_count}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ifn_count => $ifn_count }});
}
}
else
{
# Load an existing manifest.
#$anvil->Striker->load_manifest({
# debug => 2,
# manifest_uuid => $anvil->data->{cgi}{manifest_uuid}{value},
#});
}
# Show the menu
if ($anvil->data->{cgi}{step}{value} eq "1")
{
# Step 1 menu.
$anvil->data->{form}{back_link} = "?anvil=true&task=create";
$anvil->data->{form}{refresh_link} = "?anvil=true&task=create&manifest_uuid=".$anvil->data->{cgi}{manifest_uuid}{value}."&step=".$anvil->data->{cgi}{step}{value};
$anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "manifest-step1", variables => {
prefix => $prefix,
sequence => $sequence,
ifn_count => $ifn_count,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'form::body' => $anvil->data->{form}{body} }});
}
$anvil->data->{form}{back_link} = "?anvil=true&task=create";
$anvil->data->{form}{refresh_link} = "?anvil=true&task=create&manifest=new";
$anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value};
$anvil->data->{cgi}{subtask}{value} = "" if not defined $anvil->data->{cgi}{subtask}{value};
$anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
$anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "create-menu", variables => {
existing_manifests => "",
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }});
return(0); return(0);
} }
# This handles all aspects of Install Manifests. # Show the create manifest (and Fence devices and UPSes) menu
sub process_manifests sub process_create
{ {
my ($anvil) = @_; my ($anvil) = @_;
# Are we creating a new manifest? # Show existing manifests.
$anvil->data->{cgi}{manifest}{value} = "" if not defined $anvil->data->{cgi}{manifest}{value}; my $query = "
if ($anvil->data->{cgi}{manifest}{value} eq "new")
{
handle_new_manifest($anvil);
}
else
{
# Show existing manifests.
my $query = "
SELECT SELECT
manifest_uuid, manifest_uuid,
manifest_name, manifest_name,
@ -1574,48 +1650,77 @@ FROM
manifests manifests
ORDER BY ORDER BY
manifest_name ASC;"; manifest_name ASC;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results}; my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
results => $results, results => $results,
count => $count, count => $count,
}}); }});
my $manifest_template = ""; my $manifest_template = "";
if ($count) if ($count)
{
foreach my $row (@{$results})
{ {
foreach my $row (@{$results}) my $manifest_uuid = $row->[0];
{ my $manifest_name = $row->[1];
my $manifest_uuid = $row->[0]; my $manifest_last_ran = $row->[2];
my $manifest_name = $row->[1]; my $manifest_xml = $row->[3];
my $manifest_last_ran = $row->[2]; my $manifest_note = $row->[4];
my $manifest_xml = $row->[3]; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
my $manifest_note = $row->[4]; manifest_uuid => $manifest_uuid,
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { manifest_name => $manifest_name,
manifest_uuid => $manifest_uuid, manifest_last_ran => $manifest_last_ran,
manifest_name => $manifest_name, manifest_xml => $manifest_xml,
manifest_last_ran => $manifest_last_ran, manifest_note => $manifest_note,
manifest_xml => $manifest_xml, }});
manifest_note => $manifest_note, $manifest_template .= $anvil->Template->get({file => "anvil.html", name => "existing-manifest-entry", variables => {
}}); manifest_uuid => $manifest_uuid,
$manifest_template .= $anvil->Template->get({file => "anvil.html", name => "existing-manifest-entry", variables => { manifest_name => $manifest_name,
manifest_uuid => $manifest_uuid, }});
manifest_name => $manifest_name,
}});
}
} }
}
# Store the previous CGI variables and display the new fields. # Store the previous CGI variables and display the new fields.
$anvil->data->{form}{back_link} = "?anvil=true"; $anvil->data->{form}{back_link} = "?anvil=true";
$anvil->data->{form}{refresh_link} = "?anvil=true&task=create"; $anvil->data->{form}{refresh_link} = "?anvil=true&task=create";
$anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value}; $anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value};
$anvil->data->{cgi}{subtask}{value} = "" if not defined $anvil->data->{cgi}{subtask}{value}; $anvil->data->{cgi}{subtask}{value} = "" if not defined $anvil->data->{cgi}{subtask}{value};
$anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value}; $anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
$anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "create-menu", variables => { $anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "create-menu", variables => {
existing_manifests => $manifest_template, existing_manifests => $manifest_template,
}}); }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }});
return(0);
}
# This handles all aspects of Install Manifests.
sub process_manifests
{
my ($anvil) = @_;
# Are we creating a new manifest?
$anvil->data->{cgi}{manifest_uuid}{value} = "" if not defined $anvil->data->{cgi}{manifest_uuid}{value};
$anvil->data->{cgi}{run}{value} = "" if not defined $anvil->data->{cgi}{run}{value};
$anvil->data->{cgi}{step}{value} = 1 if not defined $anvil->data->{cgi}{step}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::manifest_uuid::value' => $anvil->data->{cgi}{manifest_uuid}{value},
}});
# Are we running a manifest, or creating/editing one?
if ($anvil->data->{cgi}{run}{value})
{
#run_manifest($anvil);
}
elsif ($anvil->data->{cgi}{manifest_uuid}{value})
{
handle_manifest($anvil);
}
else
{
# Uhhhh...
} }
return(0); return(0);

@ -34,7 +34,7 @@
</tr> </tr>
<tr> <tr>
<td class="main_option_icon"> <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> <a href="?anvil=true&task=manifests&manifest_uuid=new&step=1"><img src="#!data!skin::url!#/images/manifest.png" class="top_icon" ></a>
</td> </td>
<td class="main_option"> <td class="main_option">
<a href="?anvil=true&task=manifests&manifest=new">#!string!striker_0204!#</a> <a href="?anvil=true&task=manifests&manifest=new">#!string!striker_0204!#</a>
@ -66,7 +66,7 @@
</table> </table>
<!-- end create-menu --> <!-- end create-menu -->
<!-- start new-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>
<tr> <tr>
@ -99,45 +99,47 @@
<form name="manifest_step1" action="" method="post"> <form name="manifest_step1" action="" method="post">
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<tr> <tr>
<td class="header"> <td class="column_header">
<!-- prefix --> <!-- prefix -->
#!string!striker_0228!# #!string!striker_0228!#
</td> </td>
<td> <td>
&nbsp; <input type="text" name="prefix" id="prefix" value="#!variable!prefix!#" placeholder="xx" />
</td> </td>
<td class="header"> </tr>
<tr>
<td class="column_header">
<!-- Sequence --> <!-- Sequence -->
#!string!striker_0229!# #!string!striker_0229!#
</td> </td>
<td>
<input type="text" name="sequence" id="sequence" value="#!variable!sequence!#" placeholder="1" />
</td>
</tr> </tr>
<!-- TODO: Left off here, add IFN count and make the above "[ ]-anvil-[ ]". -->
<tr> <tr>
<td class="column_header">
<!-- IFN Count -->
#!string!striker_0230!#
</td>
<td> <td>
<input type="text" name="prefix" id="prefix" value="#!variable!prefix!#" placeholder="xx-" /> <input type="text" name="ifn_count" id="ifn_count" value="#!variable!ifn_count!#" placeholder="1" />
<input type="hidden" name="default_prefix" id="default_prefix" value="#!variable!default_prefix!#"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td colspan="2">
<input type="text" name="sequence" id="sequence" value="#!variable!sequence!#" placeholder="#" /> &nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="close_top"> <td>
&nbsp;<br />
<input type="submit" name="back" id="back" value="#!string!striker_0098!#" class="button"> <input type="submit" name="back" id="back" value="#!string!striker_0098!#" class="button">
</td> </td>
<td class="close_top" style="text-align: right;" colspan="#!variable!span_count!#"> <td style="text-align: right;">
&nbsp;<br /> <input type="submit" name="next" id="next" value="#!string!striker_0013!#" class="button">
<input type="submit" name="save" id="save" value="#!string!striker_0067!#" class="button">
</td> </td>
<input type="hidden" name="fence_agent" id="fence_agent" value="#!data!cgi::fence_agent::value!#"> <input type="hidden" name="step" id="step" value="2">
<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="anvil" id="anvil" value="true">
<input type="hidden" name="task" id="task" value="fences"> <input type="hidden" name="task" id="task" value="fences">
<input type="hidden" name="confirm" id="confirm" value="true">
</tr> </tr>
</table> </table>
</form> </form>
@ -149,7 +151,7 @@
</td> </td>
</tr> </tr>
</table> </table>
<!-- end new-manifest-step1 --> <!-- end manifest-step1 -->
<!-- start fence-agent-configuration --> <!-- start fence-agent-configuration -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">

@ -1323,8 +1323,8 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0223">This is the unique name (often the host name) of this specific fence device.</key> <key name="striker_0223">This is the unique name (often the host name) of this specific fence device.</key>
<key name="striker_0224">Existing fence devices:</key> <key name="striker_0224">Existing fence devices:</key>
<key name="striker_0225">Confirm deleting '#!variable!name!#'</key> <key name="striker_0225">Confirm deleting '#!variable!name!#'</key>
<key name="striker_0226">New Manifest; Step 1</key> <key name="striker_0226">Install Manifest; Step 1</key>
<key name="striker_0227">These questions will setup the values pre-filled into step 2, which will hopefully simplify filling the next, longer form.</key> <key name="striker_0227">First step are some simple questions to know what kind of Anvil! this manifest will build.</key>
<key name="striker_0228">Anvil! prefix:</key> <key name="striker_0228">Anvil! prefix:</key>
<key name="striker_0229">Anvil! Sequence:</key> <key name="striker_0229">Anvil! Sequence:</key>
<key name="striker_0230"><![CDATA[Number of <a href="https://www.alteeve.com/w/IFN" target="_new">IFNs</a>.]]></key> <key name="striker_0230"><![CDATA[Number of <a href="https://www.alteeve.com/w/IFN" target="_new">IFNs</a>.]]></key>

Loading…
Cancel
Save