var iframeTimer; /** * Execute when the DOM is fully loaded */ $(document).ready(function() { // Load utility scripts }); /** * Constructor * * @return Nothing */ var hmcPlugin = function() { }; /** * Steps for hardware discovery wizard * * @return Discovery steps */ hmcPlugin.prototype.getStep = function() { return [ 'Basic patterns', 'Supernode', 'More patterns', 'Power on hardware', 'Discover frames', 'Discover hmcs', 'Management node', 'Discover Rest of Hardware and Update Definitions', 'Create LPARs' ]; }; hmcPlugin.prototype.getInitFunction = function() { return [ powerInitBasicPattern, powerInitSupernode, powerInitSiteTable, powerInitPoweronHardware, powerInitDiscoverFrames, powerInitDiscoverHmc, powerInitConfig, powerInitUpdateDefinition, powerInitCreateLpar ]; }; hmcPlugin.prototype.getNextFunction = function() { return [ checkBasicPattern, checkSupernode, checkSiteTable, undefined, checkFrameMtms, checkHmcMtms, undefined, undefined, collectInputValue ]; }; /** * Load node inventory * * @param data Data from HTTP request */ hmcPlugin.prototype.loadInventory = function(data) { // Get arguments var args = data.msg.split(','); // Get tab ID var tabId = args[0].replace('out=', ''); // Get node var node = args[1].replace('node=', ''); // Get node inventory var inv = data.rsp; // Remove loader $('#' + tabId).find('img').remove(); // Create division to hold inventory var invDivId = tabId + 'Inventory'; var invDiv = $('
'); // Loop through each line var fieldSet = null; var legend = null; var oList = null; var item = null; for (var k = 0; k < inv.length; k++) { // Remove node name in front var str = inv[k].replace(node + ': ', ''); str = jQuery.trim(str); // If string is a header if (str.indexOf('I/O Bus Information') > -1 || str.indexOf('Machine Configuration Info') > -1) { // Create a fieldset fieldSet = $(''); legend = $(''); fieldSet.append(legend); oList = $('Frames: | |||
Name Range: | '; // Use the super node to configure file and calculate the CEC's number showString += ' | ||
Vlan1 IP Header: | Vlan2 IP Header: | ' + '||
Drawers: | |||
Name Range: | '; showString += ' | Number of LPARs per Drawer: | |
Lpars: | |||
Name Range: | Starting IP Adress: | ||
HMCs: | |||
Name Range: | '; showString += ' | Number of Frames per HMC: | |
Starting IP Adress: | '; showString += ' | Hardware Managment: | HMC '; showString += 'DFM |
Building Block | |||
Frame amount per BB: | ' + '' + ' | CEC amount per BB: | ' + '' + ' |
' + frameArray[i] + ': |
Domain Name: | |
Name server: | |
DHCP Dynamic Range: | - |
admin password for FRAME and CEC: | |
general password for FRAME and CEC: | |
hmc password for FRAME and CEC: |
' + data.rsp + ''); var ipvlan1 = 'addr:' + getDiscoverEnv('vlan1ip') + '\.[0-9]+\.[0-9]+\.[0-9]+'; var ipvlan2 = 'addr:' + getDiscoverEnv('vlan2ip') + '\.[0-9]+\.[0-9]+\.[0-9]+'; var lines = data.rsp.split('\n'); var iparray = new Array(); var re1 = new RegExp(ipvlan1,"i"); var re2 = new RegExp(ipvlan2,"i"); for (var i in lines){ var line = lines[i]; if (line.match(ipvlan1)){ var temp = re1.exec(line); iparray.push(temp[0].substr(5)); } if (line.match(ipvlan2)){ var temp = re2.exec(line); iparray.push(temp[0].substr(5)); } } setDiscoverEnv('ipfordiscovery', iparray.join(',')); } }); createDiscoverButtons(); } /** * Step 4: Check that the inputs are all filled */ function checkSiteTable(operType) { $('#discoverContentDiv input[name=ipStart]').trigger('change'); collectInputValue(); if ('back' == operType) { return true; } $('#discoverContentDiv .ui-state-error').remove(); var errMessage = ''; if (!getDiscoverEnv('domainname')) { errMessage += 'Input the domain name.
' + ' |
' + frameArray[i] + '
'); } for (var i in mtmsArray) { $('#mtmsTd').append( '' + mtmsArray[i] + '
'); } createDiscoverButtons(); } }); } function parseMtmsMap(responseText){ var typeflag; var nodeArray; if ($('#discoverContentDiv h2').text().toLocaleLowerCase().indexOf('hmc') >= 0){ typeflag = 'hmc'; nodeArray= expandNR(getDiscoverEnv('hmcName')); } else{ typeflag = 'frame'; nodeArray= expandNR(getDiscoverEnv('frameName')); } //replace the \r\n for different os file eol format responseText = responseText.replace(/[\r\n]+/g, ";"); var lines = responseText.split(";"); var temphash = new Object(); var nulldefine = ''; for(var i in lines){ var temparray = lines[i].split(" "); var tempname = temparray[0]; var tempmtm = temparray[1]; var tempserial = temparray[2]; temphash[tempname] = tempmtm + '-' + tempserial; } for (var i in nodeArray){ var tempname = nodeArray[i]; if (!temphash[tempname]){ if (!nulldefine){ nulldefine += tempname; } else{ nulldefine += ',' + tempname; } } } if (nulldefine){ $('#discoverdisc div').html( 'Error: ' + nulldefine + ' was not defined in the map file, please check!'); return; } else{ for (var i in temphash){ showMap(i, temphash[i], 0, 'Frame and MTMS map'); } } createDiscoverButtons(); } function createMap(obj, fieldtitle) { var fname = ''; var mname = ''; if ($('#discoverShow :checked').size() < 2) { return; } if ('frameradio' == $(obj).attr('name')) { fname = $(obj).next().html(); mname = $('#discoverShow input[name=mtmsradio]:checked').next().html(); } else { fname = $('#discoverShow input[name=frameradio]:checked').next().html(); mname = $(obj).next().html(); } $('#discoverShow :checked').parent().remove(); showMap(fname, mname, 1, fieldtitle); } function showMap(fname, mname, deleteflag, fieldtitle) { var rowClass = ''; var deleteicon = ''; if ($('#discoverShow fieldset').size() < 1) { $('#discoverShow') .append( ''); } if (0 == $('#discoverShow fieldset tr').size() % 2) { rowClass = 'odd'; } else { rowClass = 'even'; } if (deleteflag){ deleteicon = '' + fname + '
'); $('#mtmsTd').append( '' + mname + '
'); } /** * Step 6: Write the frame and MTMs map file */ function checkFrameMtms(operType) { // Check the number of radio button var vpdFileCon = ''; $('#discoverShow .ui-state-error').remove(); if (0 < $('#discoverShow :radio').size()) { var warnBar = createWarnBar('Map all of the frame with mtms.'); $('#discoverContentDiv #discoverShow').prepend(warnBar); return false; } // Find out all maps var maps = ''; $('#discoverShow fieldset tr').each( function() { var fname = $(this).children().eq(0).html(); var mtms = $(this).children().eq(2).html(); var pos = mtms.lastIndexOf('-'); var startpos = mtms.indexOf(':'); maps += (fname + ',' + mtms + ';'); vpdFileCon += fname + ':\n'; vpdFileCon += ' objtype=node\n serial=' + mtms.substring(pos + 1) + '\n'; vpdFileCon += ' mtm=' + mtms.substring(startpos + 1, pos) + '\n side=A\n'; }); maps = maps.substr(0, maps.length - 1); setDiscoverEnv('framemtmsmap', maps); if ('back' == operType) { return true; } // Write the maps into vpd table $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'writeconfigfile;/tmp/webvpd.stanza;' + vpdFileCon, msg : '' } }); return true; } /** * Step 7: define the hmc mtms map */ function powerInitDiscoverHmc() { $('#discoverContentDiv').empty(); $('.tooltip').remove(); var showDiv = 'Discovere HMCs and define into xCAT database.
'); var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-w;-s;HMC;-t;2;'; if (getDiscoverEnv('ipfordiscovery')){ cmdlink += '-i;' + getDiscoverEnv('ipfordiscovery') + ';'; } cmdlink += '-C;' + expandNR(getDiscoverEnv('hmcName')).length; cmdlink += '&msg=&opts=flush'; var hmciframe1 = $('').attr('src', cmdlink).css({ 'display': 'block', 'border': '0px', 'margin': '10px', 'width': '100%' }); $('#returninfo div').append(hmciframe1); hmciframe1.load(function() { $('#hmcLine1 img').remove(); var tempSpan = $('#hmcLine1').find('span'); tempSpan.removeClass('ui-icon-gear'); tempSpan.addClass('ui-icon-check'); lsslpWriteFrame(); }); } /** * Step 9: Write all lsslp frame info into the database */ function lsslpWriteFrame() { $('#frameLine1').append(createLoader()); $('#returninfo div').append('Write the discovered FRAMES into xCAT Database.
'); var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-w;-s;FRAME;'; if (getDiscoverEnv('ipfordiscovery')){ cmdlink += '-i;' + getDiscoverEnv('ipfordiscovery'); } cmdlink += '&msg=&opts=flush'; var frameiframe1 = $('').attr('src', cmdlink).css({ 'display': 'block', 'border': '0px', 'margin': '10px', 'width': '100%' }); $('#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(); }); } /** * Step 9: config the frame dhcp and dns */ function frameSetup() { $('#frameLine2').append(createLoader()); var tempargs = getDiscoverEnv('adminpasswd') + ';' + getDiscoverEnv('generalpasswd') + ';' + getDiscoverEnv('hmcpasswd'); $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'framesetup;' + tempargs + ';1', msg : '' }, success : function(data) { $('#frameLine2 img').remove(); var tempSpan = $('#frameLine2').find('span'); tempSpan.removeClass('ui-icon-gear'); tempSpan.addClass('ui-icon-check'); $('#returninfo div').append('' + data.rsp.join("\n") + ''); frameReset(); } }); } /** * Step 9: reset the networks for frames */ function frameReset(){ $('#frameLine3').append(createLoader()); $('#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%' }); $('#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(); }); } /** * Step 9: create hardware connection for frames */ function frameHwconn(){ $('#frameLine4').append(createLoader()); var tempargs = getDiscoverEnv('adminpasswd') + ';' + getDiscoverEnv('generalpasswd') + ';' + getDiscoverEnv('hmcpasswd'); $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'framesetup;' + tempargs + ';2', msg : '' }, success : function(data) { $('#frameLine4 img').remove(); var tempSpan = $('#frameLine4').find('span'); tempSpan.removeClass('ui-icon-gear'); tempSpan.addClass('ui-icon-check'); $('#returninfo div').append('' + data.rsp.join("\n") + ''); lsslpWriteCec(); } }); } /** * Step 9: Write all the lsslp cec info into database */ function lsslpWriteCec() { $('#cecLine').append(createLoader()); $('#returninfo div').append('Discover and write CECs into xCAT Database.
'); var cmdlink = 'lib/cmd.php?cmd=lsslp&tgt=&args=-s;CEC;-w;'; if (getDiscoverEnv('ipfordiscovery')){ cmdlink += '-i;' + getDiscoverEnv('ipfordiscovery'); } cmdlink += '&msg=&opts=flush'; var ceciframe1 = $('').attr('src', cmdlink).css({ 'display': 'block', 'border': '0px', 'margin': '10px', 'width': '100%' }); $('#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(); }); } /** * Step 9: config the cec dhcp and dns */ function cecsetup(){ $('#cecLine2').append(createLoader()); var tempargs = getDiscoverEnv('adminpasswd') + ';' + getDiscoverEnv('generalpasswd') + ';' + getDiscoverEnv('hmcpasswd'); $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'cecsetup;' + tempargs + ';1', msg : '' }, success : function(data) { $('#cecLine2 img').remove(); var tempSpan = $('#cecLine2').find('span'); tempSpan.removeClass('ui-icon-gear'); tempSpan.addClass('ui-icon-check'); $('#returninfo div').append('' + data.rsp.join("\n") + ''); cecReset(); } }); } /** * Step 9: reset the networks for cecs */ function cecReset(){ $('#cecLine3').append(createLoader()); $('#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%' }); $('#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(); }); } /** * Step 9: config the cec */ function cecHwconn(){ $('#cecLine4').append(createLoader()); var tempargs = getDiscoverEnv('adminpasswd') + ';' + getDiscoverEnv('generalpasswd') + ';' + getDiscoverEnv('hmcpasswd'); $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'webrun', tgt : '', args : 'cecsetup;' + tempargs + ';2', msg : '' }, success : function(data) { $('#cecLine4 img').remove(); var tempSpan = $('#cecLine4').find('span'); tempSpan.removeClass('ui-icon-gear'); tempSpan.addClass('ui-icon-check'); $('#returninfo div').append('' + data.rsp.join("\n") + ''); clearTimeout(iframeTimer); updateFrameHeight(); createDiscoverButtons(); } }); } /** * Step 10: Create LPARs */ function powerInitCreateLpar() { $('#discoverContentDiv').empty(); $('.tooltip').remove(); var showDiv = $('' + steps[currentStep] + '
'); switch (getDiscoverEnv('machineType')) { case 'ih': ihCreateLpar(showDiv); break; case 'nonih': nonihCreateLpar(showDiv); break; default: break; } $('#discoverContentDiv').append(showDiv); createDiscoverButtons(); } function ihCreateLpar(parentDiv) { var showStr = 'Partition Rule:
' + 'By default, 1 partition is already created in each octant of each CEC, with all of the octant\'s CPUs and memory assigned to it. If this is the configuration you want, click Next. To customize the partition configuration, use one of the rules below.
' + 'If all the octants configuration value are same in one CEC, it will be " -r 0-7:value".
' + 'If the octants use the different configuration value in one cec, it will be "-r 0:value1,1:value2,...7:value7", or "-r 0:value1,1-7:value2".
' + 'The octants configuration value for one Octant could be 1, 2, 3, 4, 5 . The meanings of the octants configuration value are as following:
' + '1 - 1 partition with all cpus and memory of the octant
' + '2 - 2 partitions with a 50/50 split of cpus and memory
' + '3 - 3 partitions with a 25/25/50 split of cpus and memory
' + '4 - 4 partitions with a 25/25/25/25 split of cpus and memory
' + '5 - 2 partitions with a 25/75 split of cpus and memory
' + 'Define the configuration rule for one CEC, and create all Lpars on all CECs by this rule. Or ignore this step.'; parentDiv.append(createInfoBar(showStr)); parentDiv.append(''); var lparButton = createButton('Create Lpars'); parentDiv.find('td').eq(2).append(lparButton); lparButton.bind('click', function() { var reg = /(([0-7]|[0-7]-[0-7]):[1-5],)*(([0-7]|[0-7]-[0-7]):[1-5])$/g; var lparCount = 0; $('#discoverContentDiv .ui-state-error').remove(); collectInputValue(); var inputStr = getDiscoverEnv('partconf'); var testArray = reg.exec(inputStr); if (!testArray || inputStr != testArray[0]) { var warnBar = createWarnBar('Input the correct configuration rule.'); $('#discoverContentDiv').prepend(warnBar); return; } var ruleArray = inputStr.split(','); for (var i in ruleArray) { var octantCount = 0; var octantArray = ruleArray[i].split(':'); var octantRule = Number(octantArray[1]); var pos = octantArray[0].indexOf('-'); if (5 == octantRule) { octantRule = 2; } if (-1 == pos) { octantCount = 1; } else { var startIndex = Number(octantArray[0] .substring(0, pos)); var endIndex = Number(octantArray[0] .substring(pos + 1)); octantCount = endIndex - startIndex + 1; } lparCount += octantCount * octantRule; } if (getDiscoverEnv('lparNumPerCec') != lparCount) { var warnBar = createWarnBar('The LPAR number per CEC is ' + getDiscoverEnv('lparNumPerCec') + ', but the configuration ' + 'rule calculation is ' + lparCount + '.'); $('#discoverContentDiv').prepend(warnBar); return; } var diaDiv = $(''); diaDiv.append('
Partition Configuration: ' + ''); diaDiv.append(createLoader()); diaDiv.dialog({ modal : true, width : 600, title : 'Creating Lpars...' }); $('.ui-dialog-titlebar-close').hide(); var cecArray = expandNR(getDiscoverEnv('cecName')); for (var i in cecArray) { $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'mkvm', tgt : cecArray[i] + 'nodes', args : '-i;1;-m;non-interleaved;-r;' + inputStr, msg : cecArray[i] + ';' + cecArray.length }, success : function(data) { // update the dialogure var tempArray = data.msg.split(';'); updateCreateLparDia(tempArray[0], Number(tempArray[1])); } }); } }); } function updateCreateLparDia(cecname, cecNum) { $('#createLparDiv ul').append('
Creating lpars on ' + cecname + ' competed. '); if (cecNum != $('#createLparDiv li').size()) { return; } $('#createLparDiv').empty(); $('#createLparDiv').append('All lpars are created. You must:
'); var chvmButton = createButton('OK'); $('#createLparDiv').append(chvmButton); chvmButton.bind('click', function() { $('#createLparDiv').dialog('destroy'); $('#createLparDiv').remove(); }); } function nonihCreateLpar(parentDiv) { var showStr = 'The machine type is not P7 IH, so you had to create lpars by command line manually.'; parentDiv.append(createInfoBar(showStr)); return; }
1. reboot the all CECS.
' + '2.use chvm to assign the I/O slots to the new LPAR.