From c45549830fe64a0c92b0a5d335d51dbfe6eb04bf Mon Sep 17 00:00:00 2001
From: xq2005 Discover ' + hmcArray.length + ' hmcs. Add the discovered hmc into xCAT Database. ' + mapstring + ' Add the discovered HMCs into xCAT database. Write the discovered FRAMES into xCAT Database.';
showStr += '
';
@@ -1484,91 +1484,98 @@ function powerInitUpdateDefinition(operType) {
*/
function lsslpWriteHMC() {
$('#hmcLine1').append(createLoader());
- $.ajax({
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : 'discover;hmc',
- msg : ''
- },
-
- success : function(data) {
- // modify the page elements
- $('#hmcLine1 img').remove();
- var tempSpan = $('#hmcLine1').find('span');
- tempSpan.removeClass('ui-icon-gear');
- tempSpan.addClass('ui-icon-check');
- $('#hmcLine2').append(createLoader());
-
- var hmcArray = expandNR(getDiscoverEnv('hmcName'));
- var mtmsArray = data.rsp[0].split(';');
- var tempPar = '';
-
- if (hmcArray.length > mtmsArray.length) {
- // Error info
- $('#hmcLine2 img').remove();
- var warnBar = createWarnBar('Error: Defined ' + hmcArray.length
- + ' HMCs, but discovered ' + mtmsArray.length
- + ' HMCs. Please check the configuration.');
- $('#discoverContentDiv div').prepend(warnBar);
- createDiscoverButtons();
- return;
- }
- else{
- $('#returninfo div').append('
' + data.rsp[0] +'
";
+ //extract the return information from the iframe hmciframe1
+ var mtmsArray = new Array();
+ var hmclines = $(document.getElementById('hmciframe1').contentWindow.document.body).text();
+ var temparray = hmclines.split("\n");
+ for (var i in temparray){
+ var line = temparray[i].replace(/(^\s*)|(\s*$)/g, "");
+ if (line.toLowerCase().indexOf('hmc') >= 0){
+ line = line.replace(/\s+/g, " ");
+ var attrs = line.split(" ");
+ //attrs[1] is mtm, attrs[2] is serial number
+ mtmsArray.push(attrs[1], attrs[2]);
+ }
+ }
+ // modify the page elements
+ $('#hmcLine1 img').remove();
+ var tempSpan = $('#hmcLine1').find('span');
+ tempSpan.removeClass('ui-icon-gear');
+ tempSpan.addClass('ui-icon-check');
+ $('#hmcLine2').append(createLoader());
+
+ var hmcArray = expandNR(getDiscoverEnv('hmcName'));
+ var tempPar = '';
+
+ if (hmcArray.length > (mtmsArray.length / 2)) {
+ // Error info
+ $('#hmcLine2 img').remove();
+ var warnBar = createWarnBar('Error: Defined ' + hmcArray.length
+ + ' HMCs, but discovered ' + mtmsArray.length / 2
+ + ' HMCs. Please check the configuration.');
+ $('#discoverContentDiv div').prepend(warnBar);
+ createDiscoverButtons();
+ return;
+ }
+
+ // Create the HMC and MTMs pair string
+ for (var i in hmcArray) {
+ var j = 2 * i;
+ if ('' == tempPar) {
+ tempPar += hmcArray[i] + ',' + mtmsArray[j] + ',' + mtmsArray[j + 1];
+ } else {
+ tempPar += ':' + hmcArray[i] + ',' + mtmsArray[j] + ',' + mtmsArray[j + 1];
+ }
+ mapstring += hmcArray[i] + '<----->' + mtmsArray[j] + '-' + mtmsArray[j + 1] + '
';
+ }
+
+ $('#returninfo div').append('' + data.rsp.join("\n") + '
Write the discovered FRAMES into xCAT Database.
'); + var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-w;-s;FRAME&msg=&opts=flush';; + var frameiframe1 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' + }); + $('#returninfo div').append(frameiframe1); + + frameiframe1.load(function(data) { + $('#frameLine1 img').remove(); + var tempSpan = $('#frameLine1').find('span'); + tempSpan.removeClass('ui-icon-gear'); + tempSpan.addClass('ui-icon-check'); + frameSetup(); }); } @@ -1630,25 +1636,23 @@ function frameSetup() { */ function frameReset(){ $('#frameLine3').append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rspconfig', - tgt : 'frame', - args : '--resetnet', - msg : '' - }, - - success : function(data) { - $('#frameLine3 img').remove(); - var tempSpan = $('#frameLine3').find('span'); - tempSpan.removeClass('ui-icon-gear'); - tempSpan.addClass('ui-icon-check'); - $('#returninfo div').append('Reset network on FRAMES to get persistent IP.
' + data.rsp.join("\n") + ''); - frameHwconn(); - } - }); + $('#returninfo div').append('
Reset network on FRAMES to get persistent IP.
'); + var cmdlink = 'lib/cmd.php?cmd=rspconfig&tgt=frame&args=--resetnet&msg=&opts=flush';; + var frameiframe2 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' + }); + $('#returninfo div').append(frameiframe2); + frameiframe2.load(function() { + $('#frameLine3 img').remove(); + var tempSpan = $('#frameLine3').find('span'); + tempSpan.removeClass('ui-icon-gear'); + tempSpan.addClass('ui-icon-check'); + frameHwconn(); + }); } /** @@ -1684,23 +1688,22 @@ function frameHwconn(){ */ function lsslpWriteCec() { $('#cecLine').append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'lsslp', - tgt : '', - args : '-s;CEC;-w', - msg : '' - }, - success : function(data) { - $('#cecLine img').remove(); - var tempSpan = $('#cecLine').find('span'); - tempSpan.removeClass('ui-icon-gear'); - tempSpan.addClass('ui-icon-check'); - $('#returninfo div').append('Discover and write CECs into xCAT Database.
' + data.rsp.join("\n") + ''); - cecsetup(); - } + $('#returninfo div').append('
Discover and write CECs into xCAT Database.
'); + var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-s;CEC;-w&msg=&opts=flush';; + var ceciframe1 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' + }); + $('#returninfo div').append(ceciframe1); + ceciframe1.load(function() { + $('#cecLine img').remove(); + var tempSpan = $('#cecLine').find('span'); + tempSpan.removeClass('ui-icon-gear'); + tempSpan.addClass('ui-icon-check'); + cecsetup(); }); } @@ -1736,25 +1739,23 @@ function cecsetup(){ */ function cecReset(){ $('#cecLine3').append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'rspconfig', - tgt : 'cec', - args : '--resetnet', - msg : '' - }, - - success : function(data) { - $('#cecLine3 img').remove(); - var tempSpan = $('#cecLine3').find('span'); - tempSpan.removeClass('ui-icon-gear'); - tempSpan.addClass('ui-icon-check'); - $('#returninfo div').append('Reset network on CECs to get persistent IP.
' + data.rsp.join("\n") + ''); - cecHwconn(); - } - }); + $('#returninfo div').append('
Reset network on CECs to get persistent IP.
'); + var cmdlink = 'lib/cmd.php?cmd=rspconfig&tgt=cec&args=--resetnet&msg=&opts=flush';; + var ceciframe2 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' + }); + $('#returninfo div').append(ceciframe2); + ceciframe2.load(function() { + $('#cecLine3 img').remove(); + var tempSpan = $('#cecLine3').find('span'); + tempSpan.removeClass('ui-icon-gear'); + tempSpan.addClass('ui-icon-check'); + cecHwconn(); + }); } /** diff --git a/xCAT-UI/lib/functions.php b/xCAT-UI/lib/functions.php index 52935d368..19c6340d2 100644 --- a/xCAT-UI/lib/functions.php +++ b/xCAT-UI/lib/functions.php @@ -97,6 +97,10 @@ function submit_request($req, $skipVerify, $opts_array){ // Turn on output buffering ob_start(); + if ($flush){ + echo str_pad('',1024)."\n"; + } + while (!feof($fp)) { // Read until there is no more // Remove newlines and add it to the response