diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index b4e36963e..8578900f2 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -326,7 +326,16 @@ function createStatusBar(barId) { */ function createInfoBar(msg) { var infoBar = $('
'); - var msg = $('' + msg + '
'); + var icon = $('').css({ + 'display': 'inline-block', + 'margin': '10px 5px' + }); + var msg = $('' + msg + '
').css({ + 'display': 'inline-block', + 'width': '95%' + }); + + infoBar.append(icon); infoBar.append(msg); return infoBar; } @@ -563,3 +572,29 @@ function openDialog(type, msg) { } }); } + +/** + * Create an iframe to hold the output of an xCAT command + * + * @param src + * The URL of the document to show in the iframe + * @return Info box containing the iframe + */ +function createIFrame(src) { + // Put an iframe inside an info box + var infoBar = $(''); + var icon = $('').css({ + 'display': 'inline-block', + 'margin': '10px 5px' + }); + var iframe = $('').attr('src', src).css({ + 'display': 'inline-block', + 'border': '0px', + 'margin': '10px 0px', + 'width': '95%' + }); + + infoBar.append(icon); + infoBar.append(iframe); + return infoBar; +} diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php index f4e5f6679..3b5f26686 100644 --- a/xCAT-UI/lib/cmd.php +++ b/xCAT-UI/lib/cmd.php @@ -12,6 +12,7 @@ require_once "$TOPDIR/lib/jsonwrapper.php"; * @param $cmd The xCAT command * $tgt The target node or group * $args The xCAT command arguments, separated by semicolons + * $opts The xCAT command options, separated by semicolons * @return The xCAT response. Replies are in the form of JSON */ if (isset($_GET["cmd"])) { @@ -19,7 +20,7 @@ if (isset($_GET["cmd"])) { $cmd = $_GET["cmd"]; $tgt = $_GET["tgt"]; $args = $_GET["args"]; - + // Special messages put here // This gets sent back to the AJAX request as is. $msg = $_GET["msg"]; @@ -34,22 +35,41 @@ if (isset($_GET["cmd"])) { $msg = NULL; } - // If no $args is given, set $arr to NULL - if (!$args) { - $arr = array(); - } else { + // If no $args are given, set $args_array to NULL + $args_array = array(); + if ($args) { // If $args contains multiple arguments, split it into an array if (strpos($args,";")) { // Split the arguments into an array - $arr = array(); - $arr = explode(";", $args); + $args_array = array(); + $args_array = explode(";", $args); } else { - $arr = array($args); + $args_array = array($args); + } + } + + // If no $opts are given, set $opts_array to NULL + $opts_array = array(); + if (isset($_GET["opts"])) { + $opts = $_GET["opts"]; + + // If $args contains multiple arguments, split it into an array + if (strpos($opts,";")) { + // Split the arguments into an array + $opts_array = array(); + $opts_array = explode(";", $opts); + } else { + $opts_array = array($opts); } } // Submit request and get response - $xml = docmd($cmd, $tgt, $arr); + $xml = docmd($cmd, $tgt, $args_array, $opts_array); + // If the output is flushed, do not return output in JSON + if (in_array("flush", $opts_array)) { + return; + } + $rsp = array(); // webrun pping and gangliastatus output needs special handling diff --git a/xCAT-UI/lib/functions.php b/xCAT-UI/lib/functions.php index c74ffab0c..c0aa66b41 100644 --- a/xCAT-UI/lib/functions.php +++ b/xCAT-UI/lib/functions.php @@ -12,19 +12,20 @@ error_reporting(E_ALL); ini_set('display_errors', true); /** - * Description: Run a command using the xCAT client/server protocol + * Run a command using the xCAT client/server protocol * - * @param $cmd The xCAT command - * $nr Node range or group - * $args Command arguments + * @param $cmd The xCAT command + * $nr Node range or group + * $args_array Command arguments + * $opts_array Command options * @return A tree of SimpleXML objects. * See perl-xCAT/xCAT/Client.pm for the format */ -function docmd($cmd, $nr, $args){ +function docmd($cmd, $nr, $args_array, $opts_array){ // If we are not logged in, // do not try to communicate with xcatd if (!is_logged()) { - echo "docmd: Not logged in - cannot run command
"; + echo "You are not logged in! Failed to run command.
"; return simplexml_load_string('