* Fixed a bug in anvil-daemon where rebooting was clearing the reboot-needed flag.

* Finished (for now) adding support for monitoring jobs while a node is in maintenance mode!
* Cleaned up the display of job data and redid how buttons (real and classed links) are displayed to be consistent.
* Fixed a bug in anvil-daemon where a disconnect wasn't being called between loops, causing DB connections to pile up.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 93124ea3ae
commit 423fda2ad6
  1. 1
      Anvil/Tools.pm
  2. 1
      Anvil/Tools/Database.pm
  3. 11
      cgi-bin/striker
  4. 6
      html/skins/alteeve/config.html
  5. 32
      html/skins/alteeve/jobs.js
  6. 40
      html/skins/alteeve/main.css
  7. 72
      html/skins/alteeve/striker.html
  8. 3
      share/words.xml
  9. 72
      tools/anvil-daemon
  10. 4
      tools/anvil-update-system

@ -888,6 +888,7 @@ sub _set_paths
'anvil-manage-striker-peers' => "/usr/sbin/anvil-manage-striker-peers",
'anvil-prep-database' => "/usr/sbin/anvil-prep-database",
'anvil-update-states' => "/usr/sbin/anvil-update-states",
'anvil-reboot-needed' => "/usr/sbin/anvil-reboot-needed",
'anvil-report-memory' => "/usr/sbin/anvil-report-memory",
'chmod' => "/usr/bin/chmod",
'chown' => "/usr/bin/chown",

@ -1207,6 +1207,7 @@ sub disconnect
# Set the connection count to 0.
$anvil->data->{sys}{database}{connections} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::database::connections" => $anvil->data->{sys}{database}{connections} }});
return(0);
}

@ -835,11 +835,12 @@ sub check_availability
### TODO: left off here
my $job_template = $anvil->Template->get({file => "striker.html", name => "job-details", variables => {
div_id => "job_".$job_uuid,
title => $say_title,
description => $say_description,
progress_bar => "job_progress_".$job_uuid,
status => "job_status_".$job_uuid,
div_id => "job_".$job_uuid,
title => $say_title,
description => $say_description,
progress_bar => "job_progress_".$job_uuid,
progress_percent => "job_progress_percent_".$job_uuid,
status => "job_status_".$job_uuid,
}});
$jobs_list .= $job_template."\n";

@ -94,7 +94,7 @@
<td>
<br />
<hr>
<input type="submit" name="next" id="next" value="#!string!striker_0013!#">
<input type="submit" name="next" id="next" class="button" value="#!string!striker_0013!#">
</td>
</tr>
<!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. -->
@ -228,7 +228,7 @@
<td colspan="2">
<br />
<hr>
<input type="submit" name="next" id="next" value="#!string!striker_0013!#">
<input type="submit" name="next" id="next" class="button" value="#!string!striker_0013!#">
</td>
</tr>
<input type="hidden" name="bcn_count" id="bcn_count" value="#!variable!bcn_count!#">
@ -319,7 +319,7 @@
<td>
<br />
<hr>
<input type="submit" name="next" id="next" value="#!string!striker_0043!#">
<input type="submit" name="next" id="next" class="button" value="#!string!striker_0043!#">
</td>
</tr>
<!-- NOTE: For now, we support only one BCN in the web UI, but the system will be ready for N-number later. -->

@ -3,25 +3,43 @@ $.ajaxSetup({
});
// TODO: Loop through jobs found on HTML and hide and divs that aren't found in jobs.json.
$(function() {
var say_status_waiting = $('input#status_waiting').val();
if($("#running_jobs").length) {
console.log('Looking for running jobs.');
//console.log('Looking for running jobs.');
setInterval(function() {
$.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) {
$.each(data.jobs, function(index, element) {
var progress = element.job_progress
console.log('entry: ['+index+'], uuid: ['+element.job_uuid+'], progress: ['+progress+']');
//console.log('status: ['+element.job_status+']');
var progress = element.job_progress;
var status = element.job_status;
var status_length = status.length;
//console.log('entry: ['+index+'], uuid: ['+element.job_uuid+'], progress: ['+progress+']');
// Initialize
// Show the status, if there is any yet.
if (!status.length)
{
$("#job_status_"+element.job_uuid).removeClass('job_output');
$("#job_status_"+element.job_uuid).addClass('subtle_text');
$("#job_status_"+element.job_uuid).html('&lt;'+say_status_waiting+'&gt;');
//console.log('status is waiting');
}
else
{
$("#job_status_"+element.job_uuid).removeClass('subtle_text');
$("#job_status_"+element.job_uuid).addClass('job_output');
$("#job_status_"+element.job_uuid).html(status);
//console.log('status: ['+status+']');
}
// Push data
$("#job_progress_"+element.job_uuid).progressbar({value: parseInt(element.job_progress)});
$("#job_status_"+element.job_uuid).html(element.job_status);
$("#job_progress_percent_"+element.job_uuid).html(element.job_progress+'%');
});
});
}, 1000);
}
else
{
alert('Jobs status not loaded.');
//console.log('Jobs status not loaded.');
}
});

@ -121,6 +121,11 @@ td.column_header {
color: #9ba0a5;
padding: 0.15em;
}
.column_header {
text-align: left;
color: #9ba0a5;
padding: 0.15em;
}
td.column_row_name {
text-align: left;
@ -172,15 +177,15 @@ td.column_row_value_fixed_centered {
}
.config_header2 {
color: #f2f2f2;
color: #f2f2f2;
text-align: center;
font-size: 1.5em;
font-size: 1.5em;
}
.config_header3 {
color: #f2f2f2;
color: #f2f2f2;
text-align: center;
font-size: 1em;
font-size: 1em;
}
.form_group_header1 {
@ -190,8 +195,8 @@ td.column_row_value_fixed_centered {
}
.form_group_header2 {
text-align: left;
font-size: 1.1em;
text-align: left;
font-size: 1.1em;
}
table {
@ -281,8 +286,13 @@ td {
}
.button {
padding: 10px 5px;
text-align: center;
color: #343434;
font: 0.9em 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
text-decoration: none;
background-color: #f2f2f2;
padding: 5px 10px 5px 10px;
border: 1px solid #343434;
border-radius: 3px;
}
.icon_button {
@ -309,3 +319,17 @@ td {
padding: 0.2em;
font-size: 0.9em;
}
.job_table {
border-left: 1px dotted #d02724;
}
.job_status {
border: 1px solid #9ba0a5;
}
.job_output {
font: 0.8em 'Dejavu Sans Mono', Courier;
color: #d2e2d2;
white-space: nowrap;
}

@ -45,8 +45,11 @@
</td>
</tr>
<tr>
<td class="button_cell" colspan="2">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#">
<td class="button_cell" style="text-align: left;">
<a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td>
</tr>
<input type="hidden" name="new_peer_access" id="new_peer_access" value="#!data!cgi::new_peer_access::value!#">
@ -69,23 +72,26 @@
<form name="confirm-reconfig" action="" method="post">
<div id="confirm-reconfig">
<tr>
<td class="menu_title">
<td class="menu_title" colspan="2">
#!string!striker_0078!#
</td>
</tr>
<tr>
<td class="menu_details">
<td class="menu_details" colspan="2">
#!string!striker_0083!#
</td>
</tr>
<tr>
<td>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="button_cell" colspan="2">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#">
<td class="button_cell" style="text-align: left;">
<a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td>
</tr>
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
@ -101,23 +107,26 @@
<form name="confirm-update" action="" method="post">
<div id="confirm-update">
<tr>
<td class="menu_title">
<td class="menu_title" colspan="2">
#!string!striker_0078!#
</td>
</tr>
<tr>
<td class="menu_details">
<td class="menu_details" colspan="2">
#!string!striker_0086!#
</td>
</tr>
<tr>
<td>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td class="button_cell" colspan="2">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#">
<td class="button_cell" style="text-align: left;">
<a href="/cgi-bin/striker?striker=true" class="button">#!string!striker_0098!#</a>
</td>
<td class="button_cell" style="text-align: right;">
<input type="submit" name="confirm" id="confirm" class="button" value="#!string!striker_0082!#">
</td>
</tr>
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
@ -147,7 +156,7 @@
</tr>
<tr>
<td>
<a href="/" class="button">#!string!striker_0053!#</a>
<a href="/cgi-bin/striker" class="button">#!string!striker_0053!#</a>
</td>
</tr>
</table>
@ -171,7 +180,7 @@
&nbsp;
</td>
<td>
<input type="submit" name="login" id="login" value="#!string!striker_0049!#">
<input type="submit" name="login" id="login" class="button" value="#!string!striker_0049!#">
</td>
</tr>
<tr>
@ -186,7 +195,7 @@
<!-- end striker-login -->
<!-- start striker-offline -->
<table class="centered">
<table class="centered" width="90%">
<tr>
<td>
&nbsp;
@ -198,8 +207,8 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header3">#!variable!description!#</span>
<br />
<hr>
<a href="/" class="button">#!string!striker_0053!#</a>
<hr />
<a href="/cgi-bin/striker" class="button">#!string!striker_0053!#</a>
</td>
</tr>
</div>
@ -212,10 +221,11 @@
<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!#">
<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 />
<hr>
<hr />
#!variable!job_list!#
</td>
</tr>
@ -226,26 +236,32 @@
<!-- start job-details -->
<div id="#!variable!div_id!#">
<br />
<table style="border: 1px solid white">
<table class="job_table" width="90%">
<tr>
<td width="50%">
<span class="column_header">#!variable!title!#</span>
<td width="48%" style="padding-left: 4px;">
<span class="column_header">#!string!striker_0099!#:</span> #!variable!title!#
</td>
<td width="50%">
<td width="4%" class="subtle_text" style="text-align: center; white-space: nowrap;">
<div id="#!variable!progress_percent!#"></div>
</td>
<td width="48%">
<div id="#!variable!progress_bar!#"></div>
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="3" style="padding-left: 4px;">
<span class="column_row_name">#!variable!description!#</span>
</td>
</tr>
<tr>
<td colspan="2">
<div id="#!variable!status!#"></div>
<td colspan="3" style="padding: 6px;">
<div class="job_status" id="#!variable!status!#"></div>
</td>
</tr>
</table>
<br />
<hr />
<br />
</div>
<!-- end job-details -->
@ -399,7 +415,7 @@
</tr>
<tr>
<td class="button_cell" colspan="4" align="center">
<input type="submit" id="save" name="save" value="#!string!striker_0067!#" />
<input type="submit" id="save" name="save" class="button" value="#!string!striker_0067!#" />
</td>
</tr>
<input type="hidden" name="striker" value="true" />
@ -530,7 +546,7 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span>
<br />
<hr>
<hr />
<a href="/" class="button">Reload</a>
</td>
</tr>
@ -546,7 +562,7 @@
<span name="#!variable!title_id!#" id="#!variable!title_id!#" class="config_header1">#!variable!title!#</span><br />
<span name="#!variable!message_id!#" id="#!variable!message_id!#" class="config_header2">#!variable!description!#</span>
<br />
<hr>
<hr />
<a href="/" class="button">Reload</a>
</td>
</tr>

@ -467,6 +467,8 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_0095">This will power off the Striker machine and leave it off. To power it back on, you will need physical access or cycle the power of the PDU feeding this Striker.</key>
<key name="striker_0096">Recent and Running Jobs</key>
<key name="striker_0097">There are no jobs currently running or recently completed.</key>
<key name="striker_0098">Back</key>
<key name="striker_0099">Job</key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -535,6 +537,7 @@ The update appears to have not completed successfully. The output was:
<key name="js_0001">Up</key>
<key name="js_0002">Down</key>
<key name="js_0003">Mbps</key>
<key name="js_0004">waiting for job output...</key>
</language>
<!-- 日本語 -->

@ -69,7 +69,7 @@ run_once($anvil) if not $anvil->data->{switches}{'main-loop-only'};
$anvil->Storage->record_md5sums;
# Disconnect. We'll reconnect inside the loop
$anvil->Database->disconnect;
$anvil->Database->disconnect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"});
# These are the things we always want running.
@ -77,7 +77,7 @@ while(1)
{
# Connect to the database(s)
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
$anvil->Database->connect;
$anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
if ($anvil->data->{sys}{database}{connections})
@ -110,7 +110,8 @@ while(1)
$anvil->nice_exit({code => 0});
}
# Sleep now.
# Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect();
sleep 2;
}
@ -148,7 +149,7 @@ sub run_once
# Clear the reboot request.
my $output = $anvil->System->call({
debug => 2,
shell_call => $anvil->data->{path}{exe}{'anvil-clear-reboot'},
shell_call => $anvil->data->{path}{exe}{'anvil-reboot-needed'}." --set 0",
source => $THIS_FILE,
line => __LINE__,
});
@ -292,30 +293,36 @@ sub run_jobs
# Skip if this job is in progress.
if (not exists $anvil->data->{pids}{$job_picked_up_by})
{
# The previous job is gone, but the job isn't finished. Start it again.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "striker_warning_0007", variables => {
command => $job_command,
pid => $job_picked_up_by,
percent => $job_progress,
}});
# If the job is done, just clear the 'job_picked_up_by' and be done.
clear_job($anvil, $job_uuid);
if ($job_progress ne "100")
{
# The previous job is gone, but the job isn't finished. Start it again.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "striker_warning_0007", variables => {
command => $job_command,
pid => $job_picked_up_by,
percent => $job_progress,
}});
# Clear some variables.
$job_progress = 0;
$job_status = "message_0056";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
job_progress => $job_progress,
job_status => $job_status,
}});
}
# Clear some variables.
# Clear the PID
$job_picked_up_by = 0;
$job_progress = 0;
$job_status = "message_0056";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
job_picked_up_by => $job_picked_up_by,
job_progress => $job_progress,
job_status => $job_status,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_picked_up_by => $job_picked_up_by }});
}
}
# Convert the double-banged strings into a proper message.
my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
my $say_status = $job_progress ? $anvil->Words->parse_banged_string({key_string => $job_status}) : "";
my $say_status = $job_status ? $anvil->Words->parse_banged_string({key_string => $job_status}) : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
job_title => $job_title,
say_description => $say_description,
@ -323,18 +330,21 @@ sub run_jobs
}});
# Make the status HTML friendly. Strip any embedded HTML then encode the text string.
my $html_strip = HTML::Strip->new();
$say_status = $html_strip->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
# Now make the resulting text string HTML friendly
my $text_to_html = HTML::FromText->new({
urls => 1,
email => 1,
lines => 1,
});
$say_status = $text_to_html->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
if ($say_status)
{
my $html_strip = HTML::Strip->new();
$say_status = $html_strip->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
# Now make the resulting text string HTML friendly
my $text_to_html = HTML::FromText->new({
urls => 1,
email => 1,
lines => 1,
});
$say_status = $text_to_html->parse($say_status);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_status => $say_status }});
}
# Add this to the jobs.json file
my $json_string = to_json ({

@ -147,7 +147,7 @@ update_progress($anvil, 0, "clear");
update_progress($anvil, 1, "message_0033");
# Make sure maintenance mode is enabled.
$anvil->System->maintenance_mode({debug => 2, set => 1});
$anvil->System->maintenance_mode({debug => 3, set => 1});
# Run the update
run_os_update($anvil);
@ -165,7 +165,7 @@ else
}
# Clear maintenance mode.
$anvil->System->maintenance_mode({debug => 2, set => 0});
$anvil->System->maintenance_mode({debug => 3, set => 0});
$anvil->nice_exit({exit_code => 0});

Loading…
Cancel
Save