/** * 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', 'Management node', 'Discover Rest of Hardware and Update Definitions', 'Create LPARs' ]; }; hmcPlugin.prototype.getInitFunction = function() { return [ powerInitBasicPattern, powerInitSupernode, powerInitSiteTable, powerInitPoweronHardware, powerInitDiscoverFrames, powerInitConfig, powerInitUpdateDefinition, powerInitCreateLpar ]; }; hmcPlugin.prototype.getNextFunction = function() { return [ checkBasicPattern, checkSupernode, checkSiteTable, undefined, checkFrameMtms, 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 + ''); } }); 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 frameArray = expandNR(getDiscoverEnv('frameName')); var lines = responseText.split("\n"); 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 frameArray){ var tempname = frameArray[i]; if (!temphash[tempname]){ if (!nulldefine){ nulldefine += 'tempname'; } else{ nulldefine += ', tempname'; } } } if (nulldefine){ $('#framedisc 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); } } createDiscoverButtons(); } function createMap(obj) { 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); } function showMap(fname, mname, deleteflag) { 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: Create the xcatsetup configure file and run xcatsetup to define all * objects in xcat database. */ function powerInitConfig(operType) { $('#discoverContentDiv').empty(); $('.tooltip').remove(); var showStr = '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] +'
Write the discovered FRAMES into xCAT Database.
' + data.rsp.join("\n") + ''); frameSetup(); } }); } /** * Step 8: 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 8: reset the networks for frames */ 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(); } }); } /** * Step 8: 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 8: Write all the lsslp cec info into database */ 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(); } }); } /** * Step 8: 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 8: reset the networks for cecs */ 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(); } }); } /** * Step 8: 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") + ''); createDiscoverButtons(); } }); } /** * Step 9: 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:
' + '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.