2007-11-02 19:42:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Produces HTML for use in the interface.
|
|
|
|
*/
|
2007-11-28 19:37:25 +00:00
|
|
|
if (!$TOPDIR) { $TOPDIR = '..'; }
|
|
|
|
require_once "$TOPDIR/lib/functions.php";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
|
|
|
class GroupNodeTable {
|
|
|
|
|
|
|
|
|
|
|
|
function GroupNodeTable() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return A string containing the HTML for the header of the table.
|
|
|
|
*/
|
|
|
|
function insertGroupTableHeader() {
|
|
|
|
echo <<<EOS
|
|
|
|
<table border="0" cellspacing="1" cellpadding=1>
|
|
|
|
<tr class=TableHeader>
|
|
|
|
<td width="88" align=left><input type="checkbox" name="chk_node_all" id="chk_node_all">Groups</td>
|
2007-12-04 18:17:21 +00:00
|
|
|
<td>Status</td><td>Comment</td>
|
2007-11-02 19:42:07 +00:00
|
|
|
</tr>
|
2007-12-03 18:16:38 +00:00
|
|
|
|
2007-11-02 19:42:07 +00:00
|
|
|
EOS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertGroupTableFooter() {
|
|
|
|
echo "</table>";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param String nodeGroupName The name of the node group.
|
|
|
|
*/
|
|
|
|
function getToggleString($nodeGroupName) {
|
|
|
|
global $TOPDIR;
|
|
|
|
//$colTxt = "Click to collapse section";
|
|
|
|
$exTxt = "Click to expand section";
|
|
|
|
//$bulgif = "$TOPDIR/images/h3bg_new.gif";
|
|
|
|
//$minusgif = "$TOPDIR/images/minus-sign.gif";
|
|
|
|
$plusgif = "$TOPDIR/images/plus-sign.gif";
|
|
|
|
|
|
|
|
$html = <<<EOS
|
|
|
|
<span
|
|
|
|
title="$exTxt"
|
|
|
|
id="img_gr_$nodeGroupName"
|
2007-12-03 18:16:38 +00:00
|
|
|
onclick="GroupNodeTableUpdater.updateNodeList('$nodeGroupName')"
|
2007-11-02 19:42:07 +00:00
|
|
|
ondblclick="toggleSection(this,'div_$nodeGroupName')">
|
|
|
|
<img src="$plusgif" id="div_$nodeGroupName-im" name="div_$nodeGroupName-im">
|
|
|
|
EOS;
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param String nodeGroup The group.
|
|
|
|
*/
|
2007-11-24 17:44:09 +00:00
|
|
|
function insertGroupTableRow($nodeGroupName, $status) {
|
|
|
|
$img_string = getStatusImage(GroupNodeTable::determineStatus($status));
|
2007-11-02 19:42:07 +00:00
|
|
|
|
|
|
|
//echo '<tr bgcolor="#FFCC00"><td align=left>';
|
2007-12-04 18:17:21 +00:00
|
|
|
echo '<tr class=TableRow><td align=left width=140>';
|
2007-11-02 19:42:07 +00:00
|
|
|
echo GroupNodeTable::getToggleString($nodeGroupName);
|
|
|
|
echo <<<EOE
|
|
|
|
<input type="checkbox" name="chk_node_group_$nodeGroupName" id="chk_node_group_$nodeGroupName"><b>$nodeGroupName</b></span>
|
|
|
|
</td>
|
2007-12-04 18:17:21 +00:00
|
|
|
<td align=center><img src="$img_string"></td>
|
2007-11-02 19:42:07 +00:00
|
|
|
<td> </td>
|
|
|
|
</tr>
|
2007-12-04 18:17:21 +00:00
|
|
|
<tr><td colspan=3><div id=div_$nodeGroupName style="display:none"></div></td></tr>
|
2007-11-02 19:42:07 +00:00
|
|
|
EOE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-21 12:08:19 +00:00
|
|
|
// This is used by nodes_by_group.php
|
2007-11-02 19:42:07 +00:00
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* @param An array of node groups, each of which contains an array of attr/value pairs
|
2007-11-02 19:42:07 +00:00
|
|
|
* returns the table that contains all the nodes information of that group
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
function getNodeGroupSection($group, $nodes) {
|
|
|
|
global $TOPDIR;
|
|
|
|
$imagedir = "$TOPDIR/images";
|
|
|
|
$right_arrow_gif = $imagedir . "/grey_arrow_r.gif";
|
|
|
|
$left_arrow_gif = $imagedir . "/grey_arrow_l.gif";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2008-09-26 20:25:53 +00:00
|
|
|
$html = "<table id='$group' class=GroupNodeTable width='100%' cellpadding=0 cellspacing=1 border=0>\n";
|
|
|
|
$html .= "<TR class=GroupNodeTableHeader><TD>Node Name</TD><TD>Arch</TD><TD>OS</TD><TD>Profile</TD><TD>Status</TD><TD>Power Method</TD><TD>Comment</TD></TR>\n";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
foreach($nodes as $nodeName => $attrs) {
|
|
|
|
$html .= GroupNodeTable::getNodeTableRow($nodeName, $attrs);
|
|
|
|
}
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2007-12-04 18:17:21 +00:00
|
|
|
$html .= "<TR class=GroupNodeTableRow><TD colspan=9 align=right><image src='$left_arrow_gif' alt='Previous page'> <image src='$right_arrow_gif' alt='Next page'> </TD></TR>\n";
|
2007-12-03 18:16:38 +00:00
|
|
|
$html .= "</table>\n";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* @param The node for which we want to generate the html.
|
2007-11-02 19:42:07 +00:00
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
function getNodeTableRow($nodeName, $attrs) {
|
2007-12-04 18:17:21 +00:00
|
|
|
$html = "<tr class=GroupNodeTableRow>\n" .
|
|
|
|
"<td align=left><input type=checkbox name='node_$nodeName' >$nodeName</td>\n" .
|
2008-09-26 20:25:53 +00:00
|
|
|
"<td>" . (array_key_exists('nodetype.arch',$attrs)?$attrs['nodetype.arch']:'') . "</td>\n" .
|
|
|
|
"<td>" . (array_key_exists('nodetype.os',$attrs)?$attrs['nodetype.os']:'') . "</td>\n" .
|
|
|
|
"<td>" . (array_key_exists('nodetype.profile',$attrs)?$attrs['nodetype.profile']:'') . "</td>\n";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2008-09-26 20:25:53 +00:00
|
|
|
$stat = 'unknown'; //todo: implement when nodels <nr> nodelist.status works
|
2007-12-03 18:16:38 +00:00
|
|
|
$img_string = '<img src="' . getStatusImage($stat) . '">';
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2008-09-26 20:25:53 +00:00
|
|
|
$powerstr = array_key_exists('nodehm.power',$attrs) ? $attrs['nodehm.power'] : NULL;
|
|
|
|
if (empty($powerstr)) { $powerstr = array_key_exists('nodehm.mgt',$attrs)?$attrs['nodehm.mgt']:''; }
|
|
|
|
|
|
|
|
$html .= "<td align=center>" . $img_string . "</td>".
|
|
|
|
"<td>" . $powerstr . "</td>".
|
|
|
|
"<td>" . (array_key_exists('nodelist.comments',$attrs)?$attrs['nodelist.comments']:'') . "</td></tr>";
|
2007-11-02 19:42:07 +00:00
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
return $html;
|
2007-11-02 19:42:07 +00:00
|
|
|
}
|
2007-11-24 17:44:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param String nodestatStr The status of the node as output by the nodestat command
|
|
|
|
* @return "good", "bad", "warning", or "unknown"
|
|
|
|
*/
|
|
|
|
function determineStatus($statStr) {
|
|
|
|
$status = NULL;
|
2008-09-26 20:25:53 +00:00
|
|
|
if ($statStr == "alive" || $statStr == "ready" || $statStr == "pbs" || $statStr == "sshd") { $status = "good"; }
|
2007-11-24 17:44:09 +00:00
|
|
|
else if ($statStr == "noping") { $status = "bad"; }
|
|
|
|
else if ($statStr == "ping") { $status = "warning"; }
|
|
|
|
else { $status = "unknown"; }
|
|
|
|
return $status;
|
2007-11-02 19:42:07 +00:00
|
|
|
}
|
2007-11-24 17:44:09 +00:00
|
|
|
|
|
|
|
} // end the class
|
2007-11-02 19:42:07 +00:00
|
|
|
?>
|