diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js index 17d8e3575..3ca1af8ad 100644 --- a/xCAT-UI/js/custom/hmc.js +++ b/xCAT-UI/js/custom/hmc.js @@ -1310,7 +1310,7 @@ function powerInitConfig(operType) { 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('

Discover ' + hmcArray.length + ' hmcs.

'); - } - - // Create the HMC and MTMs pair string - for (var i in hmcArray) { - var tPos = mtmsArray[i].lastIndexOf('-'); - var startPos = mtmsArray[i].indexOf(':'); - if ('' == tempPar) { - tempPar += hmcArray[i] + ',' - + mtmsArray[i].substring(startPos + 1, tPos) + ',' - + mtmsArray[i].substring(tPos + 1); - } else { - tempPar += ':' + hmcArray[i] + ',' - + mtmsArray[i].substring(startPos + 1, tPos) + ',' - + mtmsArray[i].substring(tPos + 1); - } - } - - // Write MTMs and HMC name pair into vpd table - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : 'updatevpd;' + tempPar, - msg : '' - }, - success : function() { - // Run lsslp and write all info into datatable - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'lsslp', - tgt : '', - args : '-s;HMC;-w', - msg : '' - }, - success : function(data) { - $('#hmcLine2 img').remove(); - var tempSpan = $('#hmcLine2').find('span'); - tempSpan.removeClass('ui-icon-gear'); - tempSpan.addClass('ui-icon-check'); - $('#returninfo div').append('

Add the discovered hmc into xCAT Database.
' + data.rsp[0] +'

'); - lsslpWriteFrame(); - } - }); - } - }); - } + var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-s;HMC&msg=&opts=flush'; + var hmciframe1 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' }); + + hmciframe1.load( function() { + var mapstring = "Add map between hmc and frames into xCAT database
"; + //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('

' + mapstring + '

'); + + // Write MTMs and HMC name pair into vpd table + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : 'updatevpd;' + tempPar, + msg : '' + }, + success : function() { + $('#returninfo div').append('

Add the discovered HMCs into xCAT database.

'); + var cmklink2 = 'lib/cmd.php?cmd=lsslp&tgt=&args=-w;-s;HMC&msg=&opts=flush'; + var hmciframe2 = $('').attr('src', cmdlink).css({ + 'display': 'block', + 'border': '0px', + 'margin': '10px', + 'width': '100%', + 'overflow': 'visible' + }); + $('#returninfo div').append(hmciframe2); + + hmciframe2.load(function() { + $('#hmcLine2 img').remove(); + var tempSpan = $('#hmcLine2').find('span'); + tempSpan.removeClass('ui-icon-gear'); + tempSpan.addClass('ui-icon-check'); + lsslpWriteFrame(); + }); + } + }); + }); + + $('#returninfo div').append(hmciframe1); } /** @@ -1576,24 +1583,23 @@ function lsslpWriteHMC() { */ function lsslpWriteFrame() { $('#frameLine1').append(createLoader()); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'lsslp', - tgt : '', - args : '-s;FRAME;-w', - msg : '' - }, - - success : function(data) { - $('#frameLine1 img').remove(); - var tempSpan = $('#frameLine1').find('span'); - tempSpan.removeClass('ui-icon-gear'); - tempSpan.addClass('ui-icon-check'); - $('#returninfo div').append('

Write the discovered FRAMES into xCAT Database.

' + data.rsp.join("\n") + '

'); - frameSetup(); - } + $('#returninfo div').append('

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