From aa6dde8fa5f7e5a139e235268895a230b0382461 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 27 Oct 2010 02:59:50 +0000 Subject: [PATCH] add desc to the php response when the command is nodels git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7934 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/lib/cmd.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php index 1ca97f89b..6796c0126 100644 --- a/xCAT-UI/lib/cmd.php +++ b/xCAT-UI/lib/cmd.php @@ -54,7 +54,7 @@ if (isset($_GET["cmd"])) { // nodels output needs special handling else if(strncasecmp($cmd, "nodels", 6) == 0) { // Handle the output the same way as webrun - $rsp = extractWebrun($xml); + $rsp = extractNodels($xml); } // extnoderange output needs special handling // This command gets the nodes and groups @@ -118,6 +118,35 @@ function extractWebrun($xml) { return $rsp; } +/** + * Extract the output for a nodels command + * + * @param $xml The XML output from docmd() + * @return An array containing the output + */ +function extractNodels($xml) { + $rsp = array(); + $i = 0; + + // Extract data returned + foreach($xml->children() as $nodes){ + foreach($nodes->children() as $node){ + // Get the node name + $name = $node->name; + // Get the content + $status = $node->data->contents; + $status = str_replace(":|:", "\n", $status); + + $description = $node->data->desc; + // Add to return array + $rsp[$i] = array("$name", "$status", "$description"); + $i++; + } + } + + return $rsp; +} + /** * Extract the output for a extnoderange command *