diff --git a/xCAT-web/dsh.php b/xCAT-web/dsh.php index 1b0cf9765..e3824b3bc 100644 --- a/xCAT-web/dsh.php +++ b/xCAT-web/dsh.php @@ -6,7 +6,6 @@ $TOPDIR = '.'; $expire_time = gmmktime(0, 0, 0, 1, 1, 2038); setcookie("history", "date;hello.sh", $expire_time); -//require_once("globalconfig.php"); require_once("lib/XCAT/XCATCommand/XCATCommandRunner.class.php"); require_once "$TOPDIR/functions.php"; diff --git a/xCAT-web/dsh_action.php b/xCAT-web/dsh_action.php index 05aad75e2..6cc114886 100644 --- a/xCAT-web/dsh_action.php +++ b/xCAT-web/dsh_action.php @@ -21,8 +21,7 @@ $expire_time = gmmktime(0, 0, 0, 1, 1, 2038);
\n"; @@ -58,17 +58,17 @@ insertButtons(array( echo ''; -/* $output = array(); runcmd("\bin\sudo listattr", 2, $output); foreach ($output as $line) { echo "

line=$line

"; } */ +/* $output = array(); runcmd("/bin/sudo listattr", 2, $output); foreach ($output as $line) { echo "

line=$line

"; } */ GroupNodeTable::insertGroupTableHeader(); -// Get all the names of the groups -$xcmdr = new XCATCommandRunner(); -$nodeGroupNames = $xcmdr->getAllXCATGroups(); +// Get the names and status of the groups +$groups = getGroupStatus(); // Print the HTML for each of them -foreach($nodeGroupNames as $key => $nodeGroupName) { - echo GroupNodeTable::insertGroupTableRow($nodeGroupName); +foreach($groups as $group => $status) { + //echo "

$group status is $status

"; + echo GroupNodeTable::insertGroupTableRow($group, $status); } GroupNodeTable::insertGroupTableFooter(); @@ -77,18 +77,9 @@ echo << XCATEvent.doExpandNodes(); --> - - - - - - - - - - - - + + +
Node is good (Status is ready/pbs/sshd)
Node is bad (Status is 'noping')
Other status (unknown/node unavailable...)
Node is good (Status is ready/pbs/sshd)
Node is bad (Status is 'noping')
Other status (unknown/node unavailable...)

This interface is still under construction and not yet ready for use.

diff --git a/xCAT-web/lib/GroupNodeTable.class.php b/xCAT-web/lib/GroupNodeTable.class.php index a0595e452..1dfcc8f00 100644 --- a/xCAT-web/lib/GroupNodeTable.class.php +++ b/xCAT-web/lib/GroupNodeTable.class.php @@ -54,9 +54,8 @@ EOS; /** * @param String nodeGroup The group. */ -function insertGroupTableRow($nodeGroup) { -$nodeGroupName = $nodeGroup->getName(); -$img_string = XCATNodeGroupUtil::getImageString($nodeGroup->getStatus()); +function insertGroupTableRow($nodeGroupName, $status) { +$img_string = getStatusImage(GroupNodeTable::determineStatus($status)); //echo ''; echo ''; @@ -67,7 +66,7 @@ echo <<      - $img_string +     @@ -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 .= "\"Previous    \"Next  "; @@ -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) { "
" . $node->getMode(). "
"; $stat = $node->getStatus(); - $img_string = XCATNodeGroupUtil::getImageString($stat); + $img_string = ''; $html .= "
" . $img_string . "
". "
" . $node->getHwCtrlPt(). "
". @@ -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 = "\"Node "; - }else{ //other status - $stat_content = "\"Other "; - } - - 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 "