');
initSelectPlatform();
}
-/**
- * update the step show are on the left side of discover page
- *
- * @return nothing
- */
-function updateDiscoverStep(){
- $('#discoverStepDiv').empty();
-
- for (var index in steps){
- if (currentStep == index){
- $('#discoverStepDiv').append($('' + steps[index] + ''));
- } else {
- $('#discoverStepDiv').append($('' + steps[index] + ''));
- }
- $('#discoverStepDiv').append($(''));
- }
-
- //remove last arrow
- $('#discoverStepDiv span:last-child').remove();
-}
-
/**
* create the navigator buttons on the bottom of discover page
*
+ * @param
+ *
* @return nothing
*/
function createDiscoverButtons(){
@@ -127,7 +80,6 @@ function createNextButton(){
return;
}
currentStep ++;
- updateDiscoverStep();
initFunctions[currentStep]('next');
});
@@ -156,7 +108,7 @@ function createBackButton(){
}
currentStep--;
- updateDiscoverStep();
+
initFunctions[currentStep]('back');
});
@@ -175,7 +127,7 @@ function createBackButton(){
function getDiscoverEnv(envName){
if (discoverEnv[envName]){
return discoverEnv[envName];
- }
+ }
else{
return '';
}
@@ -299,6 +251,81 @@ function collectInputValue(){
return true;
}
+/**
+ * verify the ip address,
+ *
+ * @param
+ *
+ * @return true: for valid IP address
+ * false : for invalid IP address
+ */
+function verifyIp(ip){
+ var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/;
+ return reg.test(ip);
+}
+
+/**
+ * transfer ip into decimal
+ *
+ * @param
+ *
+ * @return decimal type ip address
+ */
+function ip2Decimal(ip){
+ if (!verifyIp(ip)){
+ return 0;
+ }
+
+ var retIp = 0;
+ var tempArray = ip.split('.');
+ for (var i = 0; i < 4; i++){
+ retIp = (retIp << 8) | parseInt(tempArray[i]);
+ }
+
+ //change the int into unsigned int type
+ retIp = retIp >>> 0;
+ return retIp;
+}
+/**
+ * calculate the end IP address by start IP and the number of IP range.
+ *
+ * @param
+ *
+ * @return
+ */
+function calcEndIp(ipStart, num){
+ var sum = 0;
+ var tempNum = Number(num);
+ var temp = /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
+ var ipArray = temp.exec(ipStart);
+
+ ipArray.shift();
+ sum = Number(ipArray[3]) + tempNum;
+ if (sum <= 254){
+ ipArray[3] = sum;
+ return (ipArray.join('.'));
+ }
+
+ ipArray[3] = sum % 254;
+
+ sum = Number(ipArray[2]) + parseInt(sum / 254);
+ if (sum <= 255){
+ ipArray[2] = sum;
+ return (ipArray.join('.'));
+ }
+
+ ipArray[2] = sum % 255;
+
+ sum = Number(ipArray[1]) + parseInt(sum / 255);
+ if (sum <= 255){
+ ipArray[1] = sum;
+ return (ipArray.join('.'));
+ }
+
+ ipArray[1] = sum % 255;
+ ipArray[0] = ipArray[0] + parseInt(sum / 255);
+ return (ipArray.join('.'));
+}
/**
* Step 1: show the wizard's function
* platform selector(system P or system X)
@@ -314,7 +341,8 @@ function initSelectPlatform(){
temp += '
This wizard will guide you through the process of defining the naming conventions within' +
'your cluster, discovering the hardware on your network, and automatically defining it in the xCAT' +
'database. Choose which type of hardware you want to discover, and then click Next.
';
- temp += ' System x hardware (not implemented yet) ';
+ temp += ' ';
+ temp += ' Blade Center ';
temp += ' System p hardware (P7 IH) ';
temp += ' System p hardware (Non P7 IH) ';
temp += '
';
@@ -338,1156 +366,36 @@ function initSelectPlatform(){
*/
function getPlatform(){
var radioValue = $('#discoverContentDiv :checked').attr('id');
+ var platformObj;
+ switch(radioValue){
+ case 'ih':
+ case 'nonih':{
+ platformObj = new hmcPlugin();
+ }
+ break;
+ case 'idataplex':{
+ platformObj = new ipmiPlugin();
+ }
+ break;
+ case 'blade':{
+
+ }
+ break;
+ }
+ steps = ['Platform'].concat(platformObj.getStep(), 'compelte');
+ initFunctions = [initSelectPlatform].concat(platformObj.getInitFunction(), complete);
+ nextFunctions = [getPlatform].concat(platformObj.getNextFunction(), undefined);
setDiscoverEnv('machineType', radioValue);
return true;
}
/**
- * Step 2: Cluster basic patterns
- * users can input the switches' name range, the number of port, start ip and port prefix
- * hmcs' name range, number and start ip
- * frames' name range, number and start ip
- * drawers' name range, number and start ip
- * @return nothing
- */
-function initBasicPattern(){
- $('#discoverContentDiv').empty();
- $('.tooltip').remove();
- var showString = '
' + steps[currentStep] + '
';
- showString += '
';
-
- //Frame title
- showString += '
Frames:
';
- //Frame Name
- showString += '
Name Range:
';
- //use the super node configure file to calculate the cec's number
- showString += '
';
-
- //CEC title
- showString += '
Drawers:
';
- //CEC name
- showString += '
Name Range:
';
- //Number of LPARs per Drawer:
- showString += '
Number of LPARs per Drawer:
';
-
- //Lpar title
- showString += '
Lpars:
';
- //lpar name
- showString += '
Name Range:
';
-
- //hmc title
- showString += '
HMCs:
';
- //hmc name
- showString += '
Name Range:
';
- //Number of Frames per HMC
- showString += '
Number of Frames per HMC:
';
- showString += '
Hardware Managment:
HMC ';
- showString += 'DFM
';
- showString += '
';
-
- $('#discoverContentDiv').append(showString);
- $('#discoverContentDiv [title]').tooltip({
- position: "center right",
- offset: [-2, 10],
- effect: "fade",
- opacity: 1
- });
-
- //change the radio inputs' checked status
- if (getDiscoverEnv('hmcFlag')){
- $('#discoverContentDiv :radio[value=hmc]').attr('checked', 'checked');
- }
- else{
- $('#discoverContentDiv :radio[value=dfm]').attr('checked', 'checked');
- }
-
- createDiscoverButtons();
-}
-
-/**
- * Step 2: check basic patterns
- * when user input the basic patterns, we should check if the input is correct.
- * @param operType
- * type of operation
- * @return true or false
- */
-function checkBasicPattern(operType){
- collectInputValue();
-
- //click back button, do not need check, only collect input value is ok.
- if ('back' == operType){
- return true;
- }
-
- $('#patternDiv .ui-state-error').remove();
-
- var errMessage = '';
- var tempName = '';
- var frameNum = 0;
- var cecNum = 0;
- var lparNum = 0;
- var hmcNum = 0;
- var cecNumPerFrame = getDiscoverEnv('cecNumPerFrame');
- var frameNumPerHmc = getDiscoverEnv('frameNumPerHmc');
- var lparNumPerCec = getDiscoverEnv('lparNumPerCec');
-
- //check the frame name
- tempName = getDiscoverEnv('frameName');
- if (!tempName){
- errMessage += 'Input the Frame Name Range. ';
- }
- else{
- frameNum = expandNR(tempName).length;
- }
-
- //check the cec name
- tempName = getDiscoverEnv('cecName');
- if (!tempName){
- errMessage += 'Input the CEC Name Range. ';
- }
- else{
- cecNum = expandNR(tempName).length;
- }
-
- //lpar number per cec
- if (!lparNumPerCec){
- errMessage += 'Input the Lpar Number Per Drawer. ';
- }
-
- //check the lpar name
- tempName = getDiscoverEnv('lparName');
- if (!tempName){
- errMessage += 'Input the Lpar Name Range. ';
- }
- else{
- lparNum = expandNR(tempName).length;
- }
-
- //check the hmc name
- tempName = getDiscoverEnv('hmcName');
- if (!tempName){
- errMessage += 'Input the HMC Name Range. ';
- }
- else{
- hmcNum = expandNR(tempName).length;
- }
-
- //frame number per hmc
- if (!frameNumPerHmc){
- errMessage += 'Input the Frame Number Per HMC. ';
- }
-
- //the hardware management type is hmc.
- if ('hmc' == $('#discoverContentDiv :checked').attr('value')){
- setDiscoverEnv('hmcFlag', true);
- }
- else{
- removeDiscoverEnv('hmcFlag');
- }
-
- //the input value check is finished.
- if ('' != errMessage){
- var warnBar = createWarnBar(errMessage);
- $('#patternDiv').prepend(warnBar);
- return false;
- }
-
- //check the connections between all numbers.
- if (getDiscoverEnv('hmcFlag')){
- if ((Number(frameNumPerHmc) * hmcNum) < frameNum){
- errMessage += 'The frame number should less than ' + Number(cecNumPerFrame) * frameNum +
- ' ("the number of hmc" * "the number of frame managed by per hmc")';
- }
- }
-
- if ((Number(lparNumPerCec) * cecNum) != lparNum){
- errMessage += 'The number of Lpars calculate by Name Range should be ' + Number(lparNumPerCec) * cecNum +
- '("the number of Drawers" * "the number of lpar per drawer")';
- }
-
- if ('' != errMessage){
- var warnBar = createWarnBar(errMessage);
- $('#patternDiv').prepend(warnBar);
- return false;
- }
-
- setDiscoverEnv('cecNum', cecNum);
- setDiscoverEnv('frameNum', frameNum);
- setDiscoverEnv('lparNum', lparNum);
- setDiscoverEnv('hmcNum', hmcNum);
- return true;
-}
-
-/**
- * Step 3: allowed the users to edit the super node condigure file
+ * last step: complete
*
- * @return nothing
- */
-function initSupernode(){
- $('#discoverContentDiv').empty();
- $('.tooltip').remove();
- $('#discoverContentDiv').append('
' + steps[currentStep] + '
');
- createDiscoverButtons();
-
- //add the introduction about the page
- var infoStr = '
The supernode-list file lists what supernode numbers should be ';
- infoStr += 'given to each CEC in each frame. Here is a sample file: ';
- infoStr += 'frame1: 0, 1, 16 frame2: 17, 32 frame3: 33, 48, 49 ';
- infoStr += 'frame4: 64 , 65, 80 frame5: 81, 96 frame6: 97(1), 112(1), 113(1), 37(1), 55, 71 ';
- infoStr += 'The name before the colon is the node name of the frame BPC. The numbers after the colon ' +
- 'are the supernode numbers to assign to the groups of CECs in that frame from bottom to top. ' +
- 'Each supernode contains 4 CECs, unless it is immediately followed by "(#)", in which case the ' +
- 'number in parenthesis indicates how many CECs are in this supernode.
';
- var InfoBar = createInfoBar(infoStr);
- $('#discoverContentDiv #supernodeDiv').append(InfoBar);
-
- var frameArray = expandNR(getDiscoverEnv('frameName'));
- var showStr = '
';
- for (var i in frameArray){
- showStr += '
' + frameArray[i] + ':
';
- }
- showStr += '
';
- $('#discoverContentDiv #supernodeDiv').append(showStr);
-}
-
-/**
- * Step 3: check the super node configure file
- *
- * @param operType
- * type of operation
- * @return true or false
- */
-function checkSupernode(operType){
- collectInputValue();
-
- if ('back' == operType){
- return true;
- }
-
- $('#supernodeDiv .ui-state-error').remove();
-
- var errString = '';
- var eceNum = 0;
- var args = '';
- var frameArray = expandNR(getDiscoverEnv('frameName'));
- for (var i in frameArray){
- var sp_config = getDiscoverEnv('sp_' + frameArray[i]);
- if (sp_config){
- eceNum += calcCec(sp_config);
- if (0 == i){
- args += frameArray[i] + ': ' + sp_config;
- }
- else{
- args += '\n' + frameArray[i] + ': ' + sp_config;
- }
- }
- else{
- errString += 'Input the super node configure for ' + frameArray[i] + ' ';
- }
- }
-
- var warnBar;
- if (errString){
- warnBar = createWarnBar(errString);
- $('#supernodeDiv').prepend(warnBar);
- return false;
- }
-
- var cecArray = expandNR(getDiscoverEnv('cecName'));
- if (eceNum != cecArray.length){
- errString += 'The number of CEC calculated from supernode configure is ' + eceNum + ', but the number ' +
- 'calculated from CECs\' Name Range is ' + cecArray.length + '. Reconfigure the supernode please.';
- warnBar = createWarnBar(errString);
- $('#supernodeDiv').prepend(warnBar);
- return false;
- }
-
- $.ajax({
- url : 'lib/systemcmd.php',
- dataType : 'json',
- data : {
- cmd : 'echo -e "' + args + '" > /tmp/websupernode.txt'
- }
- });
-
- return true;
-}
-
-function calcCec(spConfigStr){
- var tempArray = spConfigStr.split(',');
- var num = 0;
- var reg = /\(([1-4])\)/;
- for (var i in tempArray){
- var regRes = reg.exec(tempArray[i]);
- if (regRes && regRes[1]){
- num += Number(regRes[1]);
- }
- else{
- num += 4;
- }
- }
-
- return num;
-}
-
-/**
- * Step 4: show the field which need to be configured in site table
- *
- * @param operType
- * type of operation
- * @return nothing
- */
-function initSiteTable(operType){
- $('#discoverContentDiv').empty();
- $('.tooltip').remove();
- var showDiv = $('
');
-
- if (getDiscoverEnv('framemtmsmap')){
- $('#framedisc div').html('Mapping the frame name and mtms which discovered by lsslp. ' +
- 'Select the frame name, then select the mtms.');
- var mapArray = getDiscoverEnv('framemtmsmap').split(':');
- for(var i in mapArray){
- var tempArray = mapArray[i].split(',');
- showMap(tempArray[0], tempArray[1] + '-' + tempArray[2]);
- }
-
- createDiscoverButtons();
- return;
- }
-
- statBar.find('div').append('Discovering all Frames by lsslp.').append(createLoader());
-
- //use lsslp to find all bpas in cluster
- $.ajax({
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : 'discover;frame',
- msg : ''
- },
-
- success : function(data){
- var tempInfo = data.rsp[0];
- if (-1 != tempInfo.indexOf('Error')){
- $('#framedisc div').html(tempInfo);
- createDiscoverButtons();
- return;
- }
-
- var mtmsArray = tempInfo.split(';');
- var frameArray = expandNR(getDiscoverEnv('frameName'));
- //chech the defined number and discovered number
- if (mtmsArray.length != frameArray.length){
- $('#framedisc div').html('Error: Definded Number is ' + frameArray.length +
- ', but lsslp discovered Number is ' + mtmsArray.length + ', please check your configure!');
- createDiscoverButtons();
- return;
- }
-
- $('#framedisc div').html('Mapping the frame name and mtms which discovered by lsslp. ' +
- 'Select the frame name, then select the mtms.');
-
- for (var i in frameArray){
- $('#frameTd').append('
' +
- frameArray[i] + '
');
- }
-
- for (var i in mtmsArray){
- $('#mtmsTd').append('
');
- 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('
Partition Configuration:
' +
- '
');
-
- 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('
All lpars are created. You must: 1. reboot the all CECS. '+
- '2.use chvm to assign the I/O slots to the new LPAR.
');
-
- 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;
-}
-
-/**
- * Step 10: complete
- *
- * @return nothing
- */
function complete(){
$('#discoverContentDiv').empty();
$('.tooltip').remove();
diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 5b04ac68e..e39b5fc92 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -244,6 +244,38 @@ hmcPlugin.prototype.addNode = function() {
$('#pnodetype').trigger('change');
};
+hmcPlugin.prototype.getStep = function(){
+ return ['Basic Patterns',
+ 'Supernode',
+ 'More patterns',
+ 'Power on hardware',
+ 'Discover frames',
+ 'Management node',
+ '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];
+};
/**
* Add HMCs into the dialog
*
@@ -459,4 +491,1155 @@ function addPNode(){
function selectAllRscanNode(obj){
var status = $(obj).attr('checked');
$(obj).parents('table').find(':checkbox').attr('checked', status);
+}
+
+/**
+ * Step 2: Cluster basic patterns
+ * users can input the switches' name range, the number of port, start ip and port prefix
+ * hmcs' name range, number and start ip
+ * frames' name range, number and start ip
+ * drawers' name range, number and start ip
+ *
+ * @param
+ *
+ * @return
+ */
+function powerInitBasicPattern(){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ var showString = '
' + steps[currentStep] + '
';
+ showString += '
';
+ //Frame title
+ showString += '
Frames:
';
+ //Frame Name
+ showString += '
Name Range:
';
+ //use the super node configure file to calculate the cec's number
+ showString += '
';
+
+ //CEC title
+ showString += '
Drawers:
';
+ //CEC name
+ showString += '
Name Range:
';
+ //Number of LPARs per Drawer:
+ showString += '
Number of LPARs per Drawer:
';
+
+ //Lpar title
+ showString += '
Lpars:
';
+ //lpar name
+ showString += '
Name Range:
';
+
+ //hmc title
+ showString += '
HMCs:
';
+ //hmc name
+ showString += '
Name Range:
';
+ //Number of Frames per HMC
+ showString += '
Number of Frames per HMC:
';
+ showString += '
Hardware Managment:
HMC ';
+ showString += 'DFM
';
+ showString += '
';
+
+ $('#discoverContentDiv').append(showString);
+
+ $('#discoverContentDiv [title]').tooltip({
+ position: "center right",
+ offset: [-2, 10],
+ effect: "fade",
+ opacity: 1
+ });
+
+ //change the radio inputs' checked status
+ if (getDiscoverEnv('hmcFlag')){
+ $('#discoverContentDiv :radio[value=hmc]').attr('checked', 'checked');
+ }
+ else{
+ $('#discoverContentDiv :radio[value=dfm]').attr('checked', 'checked');
+ }
+
+ createDiscoverButtons();
+}
+
+/**
+ * Step 2: check basic patterns
+ * when user input the basic patterns, we should check if the input is correct.
+ * @param
+ *
+ * @return
+ */
+function checkBasicPattern(operType){
+ collectInputValue();
+
+ //click back button, do not need check, only collect input value is ok.
+ if ('back' == operType){
+ return true;
+ }
+
+ $('#patternDiv .ui-state-error').remove();
+
+ var errMessage = '';
+ var tempName = '';
+ var frameNum = 0;
+ var cecNum = 0;
+ var lparNum = 0;
+ var hmcNum = 0;
+ var cecNumPerFrame = getDiscoverEnv('cecNumPerFrame');
+ var frameNumPerHmc = getDiscoverEnv('frameNumPerHmc');
+ var lparNumPerCec = getDiscoverEnv('lparNumPerCec');
+
+ //check the frame name
+ tempName = getDiscoverEnv('frameName');
+ if (!tempName){
+ errMessage += 'Input the Frame Name Range. ';
+ }
+ else{
+ frameNum = expandNR(tempName).length;
+ }
+
+ //check the cec name
+ tempName = getDiscoverEnv('cecName');
+ if (!tempName){
+ errMessage += 'Input the CEC Name Range. ';
+ }
+ else{
+ cecNum = expandNR(tempName).length;
+ }
+
+ //lpar number per cec
+ if (!lparNumPerCec){
+ errMessage += 'Input the Lpar Number Per Drawer. ';
+ }
+
+ //check the lpar name
+ tempName = getDiscoverEnv('lparName');
+ if (!tempName){
+ errMessage += 'Input the Lpar Name Range. ';
+ }
+ else{
+ lparNum = expandNR(tempName).length;
+ }
+
+ //check the hmc name
+ tempName = getDiscoverEnv('hmcName');
+ if (!tempName){
+ errMessage += 'Input the HMC Name Range. ';
+ }
+ else{
+ hmcNum = expandNR(tempName).length;
+ }
+
+ //frame number per hmc
+ if (!frameNumPerHmc){
+ errMessage += 'Input the Frame Number Per HMC. ';
+ }
+
+ //the hardware management type is hmc.
+ if ('hmc' == $('#discoverContentDiv :checked').attr('value')){
+ setDiscoverEnv('hmcFlag', true);
+ }
+ else{
+ removeDiscoverEnv('hmcFlag');
+ }
+
+ //the input value check is finished.
+ if ('' != errMessage){
+ var warnBar = createWarnBar(errMessage);
+ $('#patternDiv').prepend(warnBar);
+ return false;
+ }
+
+ //check the connections between all numbers.
+ if (getDiscoverEnv('hmcFlag')){
+ if ((Number(frameNumPerHmc) * hmcNum) < frameNum){
+ errMessage += 'The frame number should less than ' + Number(cecNumPerFrame) * frameNum +
+ ' ("the number of hmc" * "the number of frame managed by per hmc")';
+ }
+ }
+
+ if ((Number(lparNumPerCec) * cecNum) != lparNum){
+ errMessage += 'The number of Lpars calculate by Name Range should be ' + Number(lparNumPerCec) * cecNum +
+ '("the number of Drawers" * "the number of lpar per drawer")';
+ }
+
+ if ('' != errMessage){
+ var warnBar = createWarnBar(errMessage);
+ $('#patternDiv').prepend(warnBar);
+ return false;
+ }
+
+ setDiscoverEnv('cecNum', cecNum);
+ setDiscoverEnv('frameNum', frameNum);
+ setDiscoverEnv('lparNum', lparNum);
+ setDiscoverEnv('hmcNum', hmcNum);
+ return true;
+}
+
+/**
+ * Step 3: allowed the users to edit the super node condigure file
+ *
+ * @param
+ *
+ * @return
+ */
+function powerInitSupernode(){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ $('#discoverContentDiv').append('
' + steps[currentStep] + '
');
+ createDiscoverButtons();
+
+ //add the introduction about the page
+ var infoStr = '
The supernode-list file lists what supernode numbers should be ';
+ infoStr += 'given to each CEC in each frame. Here is a sample file: ';
+ infoStr += 'frame1: 0, 1, 16 frame2: 17, 32 frame3: 33, 48, 49 ';
+ infoStr += 'frame4: 64 , 65, 80 frame5: 81, 96 frame6: 97(1), 112(1), 113(1), 37(1), 55, 71 ';
+ infoStr += 'The name before the colon is the node name of the frame BPC. The numbers after the colon ' +
+ 'are the supernode numbers to assign to the groups of CECs in that frame from bottom to top. ' +
+ 'Each supernode contains 4 CECs, unless it is immediately followed by "(#)", in which case the ' +
+ 'number in parenthesis indicates how many CECs are in this supernode.
';
+ var InfoBar = createInfoBar(infoStr);
+ $('#discoverContentDiv #supernodeDiv').append(InfoBar);
+
+ var frameArray = expandNR(getDiscoverEnv('frameName'));
+ var showStr = '
';
+ for (var i in frameArray){
+ showStr += '
' + frameArray[i] + ':
';
+ }
+ showStr += '
';
+ $('#discoverContentDiv #supernodeDiv').append(showStr);
+}
+
+/**
+ * Step 3: check the super node configure file
+ *
+ * @param
+ *
+ * @return
+ */
+function checkSupernode(operType){
+ collectInputValue();
+
+ if ('back' == operType){
+ return true;
+ }
+
+ $('#supernodeDiv .ui-state-error').remove();
+
+ var errString = '';
+ var eceNum = 0;
+ var args = '';
+ var frameArray = expandNR(getDiscoverEnv('frameName'));
+ for (var i in frameArray){
+ var sp_config = getDiscoverEnv('sp_' + frameArray[i]);
+ if (sp_config){
+ eceNum += calcCec(sp_config);
+ if (0 == i){
+ args += frameArray[i] + ': ' + sp_config;
+ }
+ else{
+ args += '\n' + frameArray[i] + ': ' + sp_config;
+ }
+ }
+ else{
+ errString += 'Input the super node configure for ' + frameArray[i] + ' ';
+ }
+ }
+
+ args += '\n';
+
+ var warnBar;
+ if (errString){
+ warnBar = createWarnBar(errString);
+ $('#supernodeDiv').prepend(warnBar);
+ return false;
+ }
+
+ var cecArray = expandNR(getDiscoverEnv('cecName'));
+ if (eceNum != cecArray.length){
+ errString += 'The number of CEC calculated from supernode configure is ' + eceNum + ', but the number ' +
+ 'calculated from CECs\' Name Range is ' + cecArray.length + '. Reconfigure the supernode please.';
+ warnBar = createWarnBar(errString);
+ $('#supernodeDiv').prepend(warnBar);
+ return false;
+ }
+
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'writeconfigfile;/tmp/websupernode.txt;' + args,
+ msg : ''
+ }
+ });
+
+ return true;
+}
+
+function calcCec(spConfigStr){
+ var tempArray = spConfigStr.split(',');
+ var num = 0;
+ var reg = /\(([1-4])\)/;
+ for (var i in tempArray){
+ var regRes = reg.exec(tempArray[i]);
+ if (regRes && regRes[1]){
+ num += Number(regRes[1]);
+ }
+ else{
+ num += 4;
+ }
+ }
+
+ return num;
+}
+
+/**
+ * Step 4: show the field which need to be configured in site table
+ *
+ * @param
+ *
+ * @return
+ */
+function powerInitSiteTable(operType){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ var showDiv = $('
');
+
+ if (getDiscoverEnv('framemtmsmap')){
+ $('#framedisc div').html('Mapping the frame name and mtms which discovered by lsslp. ' +
+ 'Select the frame name, then select the mtms.');
+ var mapArray = getDiscoverEnv('framemtmsmap').split(':');
+ for(var i in mapArray){
+ var tempArray = mapArray[i].split(',');
+ showMap(tempArray[0], tempArray[1] + '-' + tempArray[2]);
+ }
+
+ createDiscoverButtons();
+ return;
+ }
+
+ statBar.find('div').append('Discovering all Frames by lsslp.').append(createLoader());
+ //use lsslp to find all bpas in cluster
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'discover;frame',
+ msg : ''
+ },
+
+ success : function(data){
+ var tempInfo = data.rsp[0];
+ if (-1 != tempInfo.indexOf('Error')){
+ $('#framedisc div').html(tempInfo);
+ createDiscoverButtons();
+ return;
+ }
+
+ var mtmsArray = tempInfo.split(';');
+ var frameArray = expandNR(getDiscoverEnv('frameName'));
+ //chech the defined number and discovered number
+ if (mtmsArray.length != frameArray.length){
+ $('#framedisc div').html('Error: Definded Number is ' + frameArray.length +
+ ', but lsslp discovered Number is ' + mtmsArray.length + ', please check your configure!');
+ createDiscoverButtons();
+ return;
+ }
+
+ $('#framedisc div').html('Mapping the frame name and mtms which discovered by lsslp. ' +
+ 'Select the frame name, then select the mtms.');
+
+ for (var i in frameArray){
+ $('#frameTd').append('
' +
+ frameArray[i] + '
');
+
+ }
+
+ for (var i in mtmsArray){
+ $('#mtmsTd').append('
');
+ 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('
Partition Configuration:
' +
+ '
');
+
+ 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('
';
+
+ $('#discoverContentDiv').append(showString);
+
+ $('#discoverContentDiv [title]').tooltip({
+ position: "center right",
+ offset: [-2, 10],
+ effect: "fade",
+ opacity: 1
+ });
+
+ createDiscoverButtons();
+}
+
+/**
+ * step 2: collect and check the basic pattern input on page.
+ *
+ * @param
+ *
+ * @return false: the input contains error, can not go to next step
+ * true : the input are correct, go to the next step
+ */
+function idataplexCheckBasic(operType){
+ collectInputValue();
+
+ //click back button, do not need check, only collect input value is ok.
+ if ('back' == operType){
+ return true;
+ }
+
+ $('#patternDiv .ui-state-error').remove();
+ var errMessage = '';
+ var nodename = getDiscoverEnv('idataplexnodename');
+ var nodeip = getDiscoverEnv('idataplexnodeip');
+ var bmcname = getDiscoverEnv('idataplexbmcname');
+ var bmcip = getDiscoverEnv('idataplexbmcip');
+ var switchname = getDiscoverEnv('idataplexswitchname');
+ var switchip = getDiscoverEnv('idataplexswitchip');
+ var nodesperswitch = getDiscoverEnv('idataplexperswitch');
+ var nodesperframe = getDiscoverEnv('idataplexperframe');
+
+ //all fields should input
+ if (!nodename){
+ errMessage += 'Input the Nodes name. ';
+ }
+
+ if (!verifyIp(nodeip)){
+ errMessage += 'Input valid Nodes start ip. ';
+ }
+
+ if (!bmcname){
+ errMessage += 'Input the BMC name. ';
+ }
+
+ if (!verifyIp(bmcip)){
+ errMessage += 'Input valid BMC start ip. ';
+ }
+
+ if (!switchname){
+ errMessage += 'Input the switch name. ';
+ }
+
+ if (!verifyIp(switchip)){
+ errMessage += 'Input valid switch start ip. ';
+ }
+
+ if (!nodesperswitch){
+ errMessage += 'Input the nodes number per switch. ';
+ }
+
+ if (!nodesperframe){
+ errMessage += 'Input the nodes number per frame. ';
+ }
+
+ if ('' != errMessage){
+ var warnBar = createWarnBar(errMessage);
+ $('#patternDiv').prepend(warnBar);
+ return false;
+ }
+
+ //check the relations among nodes, bmcs and switches
+ var nodeNum = expandNR(nodename).length;
+ var bmcNum = expandNR(bmcname).length;
+ var switchNum = expandNR(switchname).length;
+ var tempNumber = 0;
+
+ //nodes number and bmc number
+ if (nodeNum != bmcNum){
+ errMessage += 'The number of Node must equal the number of BMC. ';
+ }
+
+ //nodes' number calculate by switches
+ tempNumber += Number(nodesperswitch) * switchNum;
+
+ if (tempNumber < nodeNum){
+ errMessage += 'Input the node number per switch correctly. ';
+ }
+
+ if ('' != errMessage){
+ var warnBar = createWarnBar(errMessage);
+ $('#patternDiv').prepend(warnBar);
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * step 3: tell users to configure the switches.
+ *
+ * @param
+ *
+ * @return
+ */
+function idataplexInitSwitch(){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ var switchArray = expandNR(getDiscoverEnv('idataplexswitchname'));
+ var switchIp = getDiscoverEnv('idataplexswitchip');
+ var showString = '
' + steps[currentStep] + '
';
+ showString += '
You defined ' + switchArray.length +' switches in last step. Configure them manually please: ';
+ showString += '
1. Start IP address: ' + switchIp + ', and the IPs must be continuous.
';
+ showString += '
2. Enable the SNMP agent on switches.
';
+ showString += '
3. If you want to use the SNMP V3, the user/password and AuthProto (default is \'md5\') should be set in the switches table.
';
+ showString += '
4. Click the next button.
';
+ showString += '';
+ $('#discoverContentDiv').append(showString);
+
+ createDiscoverButtons();
+}
+
+/**
+ * step 4: init the interface and dhcp dynamic range for hardware discovery page.
+ *
+ * @param
+ *
+ * @return
+ */
+function idataplexInitNetwork(){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ var startIp = '172.30.200.1';
+ var endIp = '172.30.255.254';
+ var showDiv = $('
' + steps[currentStep] + '
');
+ var infoBar = createInfoBar('Make sure the discovery NIC\'s IP, start IP addresses and DHCP dynamic IP range are in the same subnet.');
+ showDiv.append(infoBar);
+ //init the ip range by input
+ if (getDiscoverEnv('idataplexIpStart')){
+ startIp = getDiscoverEnv('idataplexIpStart');
+ }
+
+ if (getDiscoverEnv('idataplexIpEnd')){
+ endIp = getDiscoverEnv('idataplexIpEnd');
+ }
+ var showString = '
';
+ showString += '
DHCP Dynamic Range:
-
';
+ showString += '
';
+ showDiv.append(showString);
+
+ $('#discoverContentDiv').append(showDiv);
+
+ $('#discoverContentDiv [title]').tooltip({
+ position: "center right",
+ offset: [-2, 10],
+ effect: "fade",
+ opacity: 1
+ });
+
+ createDiscoverButtons();
+}
+
+/**
+ * step 4: check the dynamic range for dhcp
+ *
+ * @param
+ *
+ * @return
+ */
+function idataplexCheckNetwork(operType){
+ collectInputValue();
+
+ //click back button, do not need check, only collect input value is ok.
+ if ('back' == operType){
+ return true;
+ }
+
+ $('#networkDiv .ui-state-error').remove();
+ var startIp = getDiscoverEnv('idataplexIpStart');
+ var endIp = getDiscoverEnv('idataplexIpEnd');
+ var errMessage = '';
+ if(!verifyIp(startIp)){
+ errMessage += 'Input the correct start IP address. ';
+ }
+
+ if(!verifyIp(endIp)){
+ errMessage += 'Input the correct end IP address. ';
+ }
+
+ if ('' != errMessage){
+ var warnBar = createWarnBar(errMessage);
+ $('#networkDiv').prepend(warnBar);
+ return false;
+ }
+
+ if (ip2Decimal(endIp) <= ip2Decimal(startIp)){
+ var warnBar = createWarnBar('the end IP must larger than start IP. ');
+ $('#networkDiv').prepend(warnBar);
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * step 5: configure service by xcat command and restart
+ *
+ * @param
+ *
+ * @return
+ */
+function idataplexInitService(operType){
+ $('#discoverContentDiv').empty();
+ $('.tooltip').remove();
+ var showStr = '