2010-11-24 06:10:07 +00:00
|
|
|
/*associate the step name with step number*/
|
2011-12-31 06:46:13 +00:00
|
|
|
var steps = ['Platform', 'Complete'];
|
2010-11-24 06:10:07 +00:00
|
|
|
|
|
|
|
/*associate the function with step number*/
|
2011-12-31 06:46:13 +00:00
|
|
|
var initFunctions = [initSelectPlatform, complete];
|
2010-11-24 06:10:07 +00:00
|
|
|
|
|
|
|
/*associate the function witch should be called before the page changed(when click next or back)
|
2011-04-16 14:40:15 +00:00
|
|
|
*if there is no need to call functions, use undefined.*/
|
2011-12-31 06:46:13 +00:00
|
|
|
var nextFunctions = [getPlatform, undefined];
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/*save current step number*/
|
|
|
|
var currentStep = 0;
|
|
|
|
|
|
|
|
/*save user's input*/
|
|
|
|
var discoverEnv;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the discover page
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return nothing
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function loadDiscoverPage(){
|
|
|
|
currentStep = 0;
|
|
|
|
discoverEnv = new Object();
|
|
|
|
|
2010-12-03 03:25:33 +00:00
|
|
|
$('#discoverTab').append('<div class="discovercontent" id="discoverContentDiv"><div>');
|
2010-11-24 06:10:07 +00:00
|
|
|
initSelectPlatform();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the navigator buttons on the bottom of discover page
|
|
|
|
*
|
2011-12-31 06:46:13 +00:00
|
|
|
* @param
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return nothing
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function createDiscoverButtons(){
|
|
|
|
var buttonDiv = $('<div style="text-align:center;padding:20px 0px 10px 0px;"></div>');
|
|
|
|
var backButton = createBackButton();
|
|
|
|
var nextButton = createNextButton();
|
2012-01-17 06:17:25 +00:00
|
|
|
var cancelButton = createCancelButton();
|
2010-11-24 06:10:07 +00:00
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if (backButton)
|
2010-11-24 06:10:07 +00:00
|
|
|
buttonDiv.append(backButton);
|
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if (nextButton)
|
2010-11-24 06:10:07 +00:00
|
|
|
buttonDiv.append(nextButton);
|
2012-01-17 06:17:25 +00:00
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if (cancelButton)
|
2012-01-17 06:17:25 +00:00
|
|
|
buttonDiv.append(cancelButton);
|
2010-11-24 06:10:07 +00:00
|
|
|
|
|
|
|
$('#discoverContentDiv').append(buttonDiv);
|
|
|
|
}
|
|
|
|
|
2012-01-17 06:17:25 +00:00
|
|
|
function createCancelButton(){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (0 == currentStep)
|
2012-01-17 06:17:25 +00:00
|
|
|
return undefined;
|
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if ((steps.length - 1) == currentStep)
|
2012-01-17 06:17:25 +00:00
|
|
|
return undefined;
|
|
|
|
|
|
|
|
var cancelbutton = createButton('Cancel');
|
|
|
|
cancelbutton.bind('click', function(){
|
|
|
|
$('#discoverTab').empty();
|
2012-03-14 19:23:51 +00:00
|
|
|
for (var name in discoverEnv)
|
2012-01-17 06:17:25 +00:00
|
|
|
removeDiscoverEnv(name);
|
|
|
|
loadDiscoverPage();
|
|
|
|
});
|
|
|
|
|
|
|
|
return cancelbutton;
|
|
|
|
}
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
|
|
|
* create the next button base on the currentStep, the last step does not need this button
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return nothing
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function createNextButton(){
|
2011-04-06 02:23:43 +00:00
|
|
|
var tempFlag = true;
|
2012-03-14 19:23:51 +00:00
|
|
|
if ((steps.length - 1) == currentStep)
|
2010-11-24 06:10:07 +00:00
|
|
|
return undefined;
|
|
|
|
|
|
|
|
var nextButton = createButton('Next');
|
|
|
|
nextButton.bind('click', function(){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (nextFunctions[currentStep])
|
2011-04-06 02:23:43 +00:00
|
|
|
tempFlag = nextFunctions[currentStep]('next');
|
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if (!tempFlag)
|
2011-04-06 02:23:43 +00:00
|
|
|
return;
|
2010-11-24 06:10:07 +00:00
|
|
|
currentStep ++;
|
2011-04-06 02:23:43 +00:00
|
|
|
initFunctions[currentStep]('next');
|
2010-11-24 06:10:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return nextButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the next button base on the currentStep, the first step does not need this button
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return nothing
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function createBackButton(){
|
2011-04-06 02:23:43 +00:00
|
|
|
var tempFlag = true;
|
2012-03-14 19:23:51 +00:00
|
|
|
if (0 == currentStep)
|
2010-11-24 06:10:07 +00:00
|
|
|
return undefined;
|
|
|
|
|
|
|
|
var backButton = createButton('Back');
|
|
|
|
backButton.bind('click', function(){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (nextFunctions[currentStep])
|
2011-04-06 02:23:43 +00:00
|
|
|
tempFlag = nextFunctions[currentStep]('back');
|
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
if (!tempFlag)
|
2011-04-06 02:23:43 +00:00
|
|
|
return;
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
currentStep--;
|
2011-12-31 06:46:13 +00:00
|
|
|
|
2011-04-06 02:23:43 +00:00
|
|
|
initFunctions[currentStep]('back');
|
2010-11-24 06:10:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return backButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the input value on discover page
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @param envName
|
|
|
|
* value's name(discoverEnv's key)
|
2010-11-24 06:10:07 +00:00
|
|
|
* @return
|
|
|
|
* if there is assciate value, return the value.
|
|
|
|
* else return null.
|
|
|
|
*/
|
|
|
|
function getDiscoverEnv(envName){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (discoverEnv[envName])
|
2010-11-24 06:10:07 +00:00
|
|
|
return discoverEnv[envName];
|
2012-03-14 19:23:51 +00:00
|
|
|
else
|
2010-11-24 06:10:07 +00:00
|
|
|
return '';
|
|
|
|
}
|
2011-04-06 02:23:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set the input value on discover page
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @param envName
|
|
|
|
* value's name(discoverEnv's key)
|
|
|
|
* @param envValue
|
|
|
|
* value
|
|
|
|
* @return nothing
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
|
|
|
function setDiscoverEnv(envName, envValue){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (envName)
|
2011-04-06 02:23:43 +00:00
|
|
|
discoverEnv[envName] = envValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* delete the input value on discover page
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @param envName
|
|
|
|
* value's name(discoverEnv's key)
|
|
|
|
* @return nothing
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
|
|
|
function removeDiscoverEnv(envName){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (discoverEnv[envName])
|
2011-04-06 02:23:43 +00:00
|
|
|
delete discoverEnv[envName];
|
|
|
|
}
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
|
|
|
* Expand the noderange into node names.
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @param nodeRange
|
|
|
|
* @return node names array
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function expandNR(nodeRange){
|
|
|
|
var retArray = new Array();
|
|
|
|
var tempResult;
|
2012-03-14 19:23:51 +00:00
|
|
|
if ('' == nodeRange)
|
2010-11-24 06:10:07 +00:00
|
|
|
return retArray;
|
|
|
|
|
|
|
|
tempResult = nodeRange.match(/(.*?)\[(.*?)\](.*)/);
|
|
|
|
if (null != tempResult){
|
|
|
|
var parts = tempResult[2].split('-');
|
2012-03-14 19:23:51 +00:00
|
|
|
if (2 > parts.length)
|
2010-11-24 06:10:07 +00:00
|
|
|
return retArray;
|
|
|
|
|
|
|
|
var start = Number(parts[0]);
|
|
|
|
var end = Number(parts[1]);
|
|
|
|
var len = parts[0].length;
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i = parts[0]; i <= parts[1]; i++){
|
2010-11-24 06:10:07 +00:00
|
|
|
var ts = i.toString();
|
2012-03-14 19:23:51 +00:00
|
|
|
if (ts.length < len)
|
2010-11-24 06:10:07 +00:00
|
|
|
ts = "000000".substring(0, (len - ts.length)) + ts;
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
retArray = retArray.concat(expandNR(tempResult[1] + ts + tempResult[3]));
|
|
|
|
}
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var tempArray = nodeRange.split('-');
|
|
|
|
if (2 > tempArray.length){
|
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var begin = tempArray[0].match(/^(\D+)(\d+)$/);
|
2011-04-16 14:40:15 +00:00
|
|
|
if (2 > begin){
|
2010-11-24 06:10:07 +00:00
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var end = tempArray[1].match(/^(\D+)(\d+)$/);
|
2011-04-16 14:40:15 +00:00
|
|
|
if (2 > end){
|
2010-11-24 06:10:07 +00:00
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
if (begin[1] != end[1]){
|
2010-11-24 06:10:07 +00:00
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var prefix = begin[1];
|
|
|
|
var len = begin[2].length;
|
2011-04-16 14:40:15 +00:00
|
|
|
for (var i = begin[2]; i <= end[2]; i++){
|
2010-11-24 06:10:07 +00:00
|
|
|
var ts = i.toString();
|
2012-03-14 19:23:51 +00:00
|
|
|
if (ts.length < len)
|
2010-11-24 06:10:07 +00:00
|
|
|
ts = "000000".substring(0, (len - ts.length)) + ts;
|
|
|
|
retArray.push(prefix + ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
2011-04-06 02:23:43 +00:00
|
|
|
/**
|
|
|
|
* collect all inputs' value from the page
|
|
|
|
*
|
|
|
|
* @return true: this step is correct, can go to the next page
|
|
|
|
* false: this step contains error.
|
|
|
|
*/
|
|
|
|
function collectInputValue(){
|
|
|
|
$('#discoverContentDiv input[type=text]').each(function(){
|
|
|
|
var name = $(this).attr('name');
|
|
|
|
var value = $(this).attr('value');
|
2012-03-14 19:23:51 +00:00
|
|
|
if ('' != value)
|
2011-04-06 02:23:43 +00:00
|
|
|
setDiscoverEnv(name, value);
|
2012-03-14 19:23:51 +00:00
|
|
|
else
|
2011-04-06 02:23:43 +00:00
|
|
|
removeDiscoverEnv(name);
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
/**
|
|
|
|
* 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){
|
2012-03-14 19:23:51 +00:00
|
|
|
if (!verifyIp(ip))
|
2011-12-31 06:46:13 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
/**
|
|
|
|
* 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('.'));
|
|
|
|
}
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
|
|
|
* Step 1: show the wizard's function
|
|
|
|
* platform selector(system P or system X)
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return nothing
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
|
|
|
function initSelectPlatform(){
|
2011-04-06 02:23:43 +00:00
|
|
|
var type = '';
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
$('#discoverContentDiv').empty();
|
2011-04-06 02:23:43 +00:00
|
|
|
$('.tooltip').remove();
|
2012-03-14 19:23:51 +00:00
|
|
|
|
|
|
|
var selectPlatform = $('<div style="min-height:360px"><h2>' + steps[currentStep] + '</h2></div>');
|
|
|
|
|
|
|
|
var infoMsg = 'This wizard will guide you through the process of defining the naming conventions within' +
|
2010-11-24 06:10:07 +00:00
|
|
|
'your cluster, discovering the hardware on your network, and automatically defining it in the xCAT' +
|
2012-03-14 19:23:51 +00:00
|
|
|
'database. Choose which type of hardware you want to discover, and then click Next.';
|
|
|
|
var info = createInfoBar(infoMsg);
|
|
|
|
selectPlatform.append(info);
|
|
|
|
|
|
|
|
var hwList = $('<ol>Platforms available:</ol>');
|
|
|
|
hwList.append('<li><input type="radio" name="platform" id="idataplex"><label>iDataPlex</label></input></li>');
|
|
|
|
hwList.append('<li><input type="radio" name="platform" disabled="true" id="blade"><span style="color:gray;"> BladeCenter</span></input></li>');
|
|
|
|
hwList.append('<li><input type="radio" name="platform" id="ih"> System p hardware (P7 IH)</input></li>');
|
|
|
|
hwList.append('<li><input type="radio" name="platform" id="nonih"> System p hardware (Non P7 IH)</input></li>');
|
|
|
|
|
|
|
|
hwList.find('li').css('padding', '2px 10px');
|
|
|
|
selectPlatform.append(hwList);
|
2010-11-24 06:10:07 +00:00
|
|
|
|
2012-03-14 19:23:51 +00:00
|
|
|
$('#discoverContentDiv').append(selectPlatform);
|
|
|
|
|
|
|
|
if (getDiscoverEnv('machineType'))
|
2011-04-06 02:23:43 +00:00
|
|
|
type = getDiscoverEnv('machineType');
|
2012-03-14 19:23:51 +00:00
|
|
|
else
|
2011-04-06 02:23:43 +00:00
|
|
|
type = 'ih';
|
|
|
|
|
|
|
|
$('#discoverContentDiv #' + type).attr('checked', 'checked');
|
2010-11-24 06:10:07 +00:00
|
|
|
createDiscoverButtons();
|
|
|
|
}
|
|
|
|
|
2011-04-06 02:23:43 +00:00
|
|
|
/**
|
|
|
|
* Step 1: Get the platform type
|
|
|
|
*
|
2011-09-09 19:34:05 +00:00
|
|
|
* @return true
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
|
|
|
function getPlatform(){
|
|
|
|
var radioValue = $('#discoverContentDiv :checked').attr('id');
|
2011-12-31 06:46:13 +00:00
|
|
|
var platformObj;
|
|
|
|
switch(radioValue){
|
|
|
|
case 'ih':
|
2012-03-14 19:23:51 +00:00
|
|
|
case 'nonih':
|
2011-12-31 06:46:13 +00:00
|
|
|
platformObj = new hmcPlugin();
|
2012-03-14 19:23:51 +00:00
|
|
|
break;
|
|
|
|
case 'idataplex':
|
2011-12-31 06:46:13 +00:00
|
|
|
platformObj = new ipmiPlugin();
|
2012-03-14 19:23:51 +00:00
|
|
|
break;
|
|
|
|
case 'blade':
|
|
|
|
break;
|
2011-12-31 06:46:13 +00:00
|
|
|
}
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
steps = ['Platform'].concat(platformObj.getStep(), 'compelte');
|
|
|
|
initFunctions = [initSelectPlatform].concat(platformObj.getInitFunction(), complete);
|
|
|
|
nextFunctions = [getPlatform].concat(platformObj.getNextFunction(), undefined);
|
2011-04-06 02:23:43 +00:00
|
|
|
setDiscoverEnv('machineType', radioValue);
|
|
|
|
return true;
|
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
2011-12-31 06:46:13 +00:00
|
|
|
* last step: complete
|
2011-04-06 02:23:43 +00:00
|
|
|
*
|
2011-12-31 06:46:13 +00:00
|
|
|
* @param
|
2011-04-06 02:23:43 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
function complete(){
|
|
|
|
$('#discoverContentDiv').empty();
|
|
|
|
$('.tooltip').remove();
|
|
|
|
var showStr = '<div style="min-height:360px"><h2>' + steps[currentStep] + '<br/><br/></h2>';
|
|
|
|
showStr += 'You can go to the <a href="index.php">nodes page</a> to check nodes which were defined just now.';
|
|
|
|
$('#discoverContentDiv').append(showStr);
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
createDiscoverButtons();
|
|
|
|
}
|