@@ -81,7 +80,7 @@ return;
* @param XCATNodeGroup nodeGroup The node group for which we want to generate the html.
* returns the table that contains all the nodes information of that group
*/
-function getXCATNodeGroupSection($nodeGroup) {
+function getNodeGroupSection($nodeGroup) {
$imagedir = 'images';
$right_arrow_gif = $imagedir . "/grey_arrow_r.gif";
$left_arrow_gif = $imagedir . "/grey_arrow_l.gif";
@@ -97,7 +96,7 @@ EOS;
$nodes = $nodeGroup->getNodes();
foreach($nodes as $nodeName => $node) {
- $html .= GroupNodeTable::getXCATNodeTableRow($node);
+ $html .= GroupNodeTable::getNodeTableRow($node);
}
$html .= "
";
@@ -111,7 +110,7 @@ EOS;
/**
* @param XCATNode node The node for which we want to generate the html.
*/
-function getXCATNodeTableRow($node) {
+function getNodeTableRow($node) {
$imagedir = 'images';
@@ -123,7 +122,7 @@ function getXCATNodeTableRow($node) {
"
".
@@ -132,5 +131,19 @@ function getXCATNodeTableRow($node) {
EOS;
return $html;
}
+
+/**
+ * @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;
+ if ($statStr == "ready" || $statStr == "pbs" || $statStr == "sshd") { $status = "good"; }
+ else if ($statStr == "noping") { $status = "bad"; }
+ else if ($statStr == "ping") { $status = "warning"; }
+ else { $status = "unknown"; }
+ return $status;
}
+
+} // end the class
?>
diff --git a/xCAT-web/lib/XCAT/XCATCommand/XCATCommandRunner.class.php b/xCAT-web/lib/XCAT/XCATCommand/XCATCommandRunner.class.php
index 540281005..7b699d6f2 100644
--- a/xCAT-web/lib/XCAT/XCATCommand/XCATCommandRunner.class.php
+++ b/xCAT-web/lib/XCAT/XCATCommand/XCATCommandRunner.class.php
@@ -1,10 +1,8 @@
Sudo . $this->XCATRoot . "/nodels";
- $outputStat = $this->runCommand($cmdString);
-
- return $outputStat["output"];
- }
-
/**
* Will always return an up to date list of node names belonging to the group.
*
@@ -74,7 +60,7 @@ class XCATCommandRunner {
$xcn = new XCATNode();
$xcn->setName($nodeName);
- $xcn->setStatus(XCATNodeGroupUtil::determineNodeStatus($outputStat["output"][0]));
+ $xcn->setStatus($this->determineNodeStatus($outputStat["output"][0]));
$xcn->setHwType("HW Type");
$xcn->setOs("OS");
$xcn->setMode("Mode");
@@ -88,6 +74,26 @@ class XCATCommandRunner {
return $xcn;
}
+ /**
+ * @param String nodestatStr The status of the node as output by the nodestat command
+ * @return "good", "bad", or "other"
+ */
+ function determineNodeStatus($nodestatStr) {
+ $status = NULL;
+
+ if ((strpos($nodestatStr, "ready") != FALSE) ||
+ (strpos($nodestatStr, "pbs") != FALSE) ||
+ (strpos($nodestatStr, "sshd") != FALSE)) {
+ $status = 'good';
+ } else if(strpos($nodestatStr, "noping") != FALSE) {
+ $status = 'bad';
+ } else {
+ $status = 'other';
+ }
+
+ return $status;
+ }
+
/**
* @return An array containing the name of every node group.
*/
@@ -122,80 +128,5 @@ class XCATCommandRunner {
return $xcatNodeGroup;
}
-
- /**
- * This function will run the command to get all
- * the groups, and then for each group, it will get
- * their nodes, and for each node, it will get its
- * information once.
- */
- function getAllXCATGroups() {
- $xcatGroupNames = $this->getAllGroupNames();
-
- $xcatGroups = array();
-
- $groupStatArr = $this->getGroupStatus(); //get the status of all the groups
-
- foreach($xcatGroupNames as $groupName) {
- //echo "
group=$groupName
";
- $xcatGroup = $this->getXCATGroupByName($groupName, $groupStatArr);
- array_push($xcatGroups, $xcatGroup);
- }
-
-
- return $xcatGroups;
- }
-
- function getXCATGroupByName($groupName, $groupStatArr){
-
- $xcg = new XCATNodeGroup();
- $xcg->setName($groupName);
- $xcg->setStatus(XCATNodeGroupUtil::determineNodeStatus($groupStatArr[$groupName]));
-
- return $xcg;
- }
-
-
- /**
- * Will always return an up to date status of the groups
- *
- * @return An array containing the status of all the groups
- */
- function getGroupStatus() {
- $cmdString = $this->Sudo . $this->CurrDir . "/grpattr"; // "/cmds/grpattr";
- $outputStat = $this->runCommand($cmdString);
- $groupStats = $outputStat["output"];
- $groupStatArr = array();
- foreach($groupStats as $key => $groupStat) {
- if (strpos($groupStat,':') != FALSE){
- $stat = substr($groupStat,strpos($groupStat,':') + 2); //there's a space between the colon and the status
- $grp = substr($groupStat,0, strpos($groupStat,':'));
- $groupStatArr[$grp] = $stat;
- }
- }
-
- return $groupStatArr;
- }
-
- function getNodeOrGroupStatus($nodegroupName, $group) {
- $stat = "";
- if ($group == FALSE){
- $cmdString = $this->Sudo . $this->XCATRoot . "/nodestat " . $nodegroupName;
- $outputStat = $this->runCommand($cmdString);
- $nodegroupStat = $outputStat["output"][0];
-
- if (strpos($nodegroupStat,':') != FALSE){
- $stat = substr($nodegroupStat,strpos($nodegroupStat,':') + 2); //there's a space between the colon and the status
- }
- }else{
- $StatArr = $this->getGroupStatus();
- $stat = $StatArr[$nodegroupName];
- }
-
- if ($stat != "") $stat = XCATNodeGroupUtil::determineNodeStatus($stat);
-
- return $stat;
- }
-
}
?>
\ No newline at end of file
diff --git a/xCAT-web/lib/XCAT/XCATNode/XCATNodeGroupUtil.class.php b/xCAT-web/lib/XCAT/XCATNode/XCATNodeGroupUtil.class.php
deleted file mode 100644
index 2f07cf2c5..000000000
--- a/xCAT-web/lib/XCAT/XCATNode/XCATNodeGroupUtil.class.php
+++ /dev/null
@@ -1,55 +0,0 @@
- ";
- }elseif (strstr($status, "bad") == TRUE){ //node is bad
- $stat_content = " ";
- }else{ //other status
- $stat_content = " ";
- }
-
- return $stat_content;
- }
-}
-?>
diff --git a/xCAT-web/lib/XCAT/XCATNode/XCATNodeStatus.class.php b/xCAT-web/lib/XCAT/XCATNode/XCATNodeStatus.class.php
deleted file mode 100644
index e114f5ad4..000000000
--- a/xCAT-web/lib/XCAT/XCATNode/XCATNodeStatus.class.php
+++ /dev/null
@@ -1,19 +0,0 @@
-
diff --git a/xCAT-web/lib/XCAT/XCATNode/XCATNodeUtil.class.php b/xCAT-web/lib/XCAT/XCATNode/XCATNodeUtil.class.php
deleted file mode 100644
index e7d15f19d..000000000
--- a/xCAT-web/lib/XCAT/XCATNode/XCATNodeUtil.class.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
diff --git a/xCAT-web/lib/XCAT/webservice/XCATWebservice.class.php b/xCAT-web/lib/XCAT/webservice/XCATWebservice.class.php
index 418bc85dc..619ff7cbe 100644
--- a/xCAT-web/lib/XCAT/webservice/XCATWebservice.class.php
+++ b/xCAT-web/lib/XCAT/webservice/XCATWebservice.class.php
@@ -1,6 +1,6 @@
@@ -27,8 +27,8 @@ echo <<$title
-
-
+
+
EOS;
@@ -61,11 +61,11 @@ echo "\n";
echo <<
-
+
EOS;
-//echo "
\n";
+//echo "
\n";
insertMenus($currents);
@@ -366,6 +366,16 @@ function getHWTypeImage($hwtype, $powermethod) { //-----------------------------
}
+// Return the image that represents the status string passed in
+function getStatusImage($status) {
+ global $TOPDIR;
+ if ($status == 'good') { return "$TOPDIR/images/green-ball-m.gif"; }
+ elseif ($status == 'warning') { return "$TOPDIR/images/yellow-ball-m.gif"; }
+ elseif ($status == 'bad') { return "$TOPDIR/images/red-ball-m.gif"; }
+ else { return "$TOPDIR/images/blue-ball-m.gif"; }
+}
+
+
// Returns the specified user preference value. Not finished.
function getPref($key) { //------------------------------------
if ($key == 'MaxNodesDisplayed') { return 50; }
@@ -386,10 +396,25 @@ function getNodes($group, $noderange) { //------------------------------------
// Returns the node groups defined in the cluster. Not finished.
-function getGroups() { //------------------------------------
+function getGroups() {
return array('AllNodes','group1','group2');
}
+
+// Returns the aggregate status of each node group in the cluster. The return value is a
+// hash in which the key is the group name and the value is the status as returned by nodestat.
+function getGroupStatus() {
+ $groups = array();
+ $output = array();
+ runcmd("/bin/sudo grpattr", 2, $output);
+ foreach ($output as $line) {
+ //echo "
line=$line
";
+ $vals = preg_split('/: */', $line);
+ if (count($vals) == 2) { $groups[$vals[0]] = $vals[1]; }
+ }
+ return $groups;
+}
+
// Returns true if we are running on AIX ------------------------------------
function isAIX() { } //todo: implement
@@ -406,10 +431,10 @@ function insertTabs ($tablist, $currentTabIndex) { //---------------------------
foreach ($tablist as $key => $tab) {
if ($key != 0) { echo "