2012-05-04 14:45:17 +00:00
|
|
|
// Associate the step name with step number
|
|
|
|
var steps = [ 'Platform', 'Complete' ];
|
2010-11-24 06:10:07 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Associate the function with step number
|
|
|
|
var initFunctions = [ initSelectPlatform, complete ];
|
|
|
|
var nextFunctions = [ getPlatform, undefined ];
|
2010-11-24 06:10:07 +00:00
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Save current step number
|
2010-11-24 06:10:07 +00:00
|
|
|
var currentStep = 0;
|
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
// Save user's input
|
2010-11-24 06:10:07 +00:00
|
|
|
var discoverEnv;
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Create the discovery page
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function loadDiscoverPage() {
|
|
|
|
currentStep = 0;
|
|
|
|
discoverEnv = new Object();
|
|
|
|
|
|
|
|
$('#discoverTab').append('<div class="discovercontent" id="discoverContentDiv"><div>');
|
|
|
|
initSelectPlatform();
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Create the navigation buttons on the bottom of discovery page
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function createDiscoverButtons() {
|
|
|
|
var buttonDiv = $('<div style="text-align:center;padding:20px 0px 10px 0px;"></div>');
|
|
|
|
var backButton = createBackButton();
|
|
|
|
var nextButton = createNextButton();
|
|
|
|
var cancelButton = createCancelButton();
|
|
|
|
|
|
|
|
if (backButton)
|
|
|
|
buttonDiv.append(backButton);
|
|
|
|
|
|
|
|
if (nextButton)
|
|
|
|
buttonDiv.append(nextButton);
|
|
|
|
|
|
|
|
if (cancelButton)
|
|
|
|
buttonDiv.append(cancelButton);
|
|
|
|
|
|
|
|
$('#discoverContentDiv').append(buttonDiv);
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
function createCancelButton() {
|
|
|
|
if (0 == currentStep)
|
|
|
|
return undefined;
|
|
|
|
|
|
|
|
if ((steps.length - 1) == currentStep)
|
|
|
|
return undefined;
|
|
|
|
|
|
|
|
var cancelbutton = createButton('Cancel');
|
|
|
|
cancelbutton.bind('click', function() {
|
|
|
|
$('#discoverTab').empty();
|
|
|
|
for (var name in discoverEnv)
|
|
|
|
removeDiscoverEnv(name);
|
|
|
|
loadDiscoverPage();
|
|
|
|
});
|
|
|
|
|
|
|
|
return cancelbutton;
|
2012-01-17 06:17:25 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Create the next button base on the current step,
|
|
|
|
* the last step does not need this button
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function createNextButton() {
|
|
|
|
var tempFlag = true;
|
|
|
|
if ((steps.length - 1) == currentStep)
|
|
|
|
return undefined;
|
|
|
|
|
|
|
|
var nextButton = createButton('Next');
|
|
|
|
nextButton.bind('click', function() {
|
|
|
|
if (nextFunctions[currentStep])
|
|
|
|
tempFlag = nextFunctions[currentStep]('next');
|
|
|
|
|
|
|
|
if (!tempFlag)
|
|
|
|
return;
|
|
|
|
currentStep++;
|
|
|
|
initFunctions[currentStep]('next');
|
|
|
|
});
|
|
|
|
|
|
|
|
return nextButton;
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Create the next button base on the current step,
|
|
|
|
* the first step does not need this button
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function createBackButton() {
|
|
|
|
var tempFlag = true;
|
2012-07-23 10:28:14 +00:00
|
|
|
var tempButton;
|
2012-05-04 14:45:17 +00:00
|
|
|
if (0 == currentStep)
|
|
|
|
return undefined;
|
|
|
|
|
2012-07-23 10:28:14 +00:00
|
|
|
if ((steps.length - 1) == currentStep){
|
|
|
|
tempButton = createButton('Complete');
|
|
|
|
tempButton.bind('click', function() {
|
|
|
|
window.location.href="index.php";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
var tempButton = createButton('Back');
|
|
|
|
tempButton.bind('click', function() {
|
|
|
|
if (nextFunctions[currentStep])
|
|
|
|
tempFlag = nextFunctions[currentStep]('back');
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2012-07-23 10:28:14 +00:00
|
|
|
if (!tempFlag)
|
|
|
|
return;
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2012-07-23 10:28:14 +00:00
|
|
|
currentStep--;
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2012-07-23 10:28:14 +00:00
|
|
|
initFunctions[currentStep]('back');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2012-07-23 10:28:14 +00:00
|
|
|
return tempButton;
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Get the input value on discovery page
|
2010-11-24 06:10:07 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param envName Value name (discoverEnv key)
|
|
|
|
* @return If there is an associate value, return the value, else return NULL
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function getDiscoverEnv(envName) {
|
|
|
|
if (discoverEnv[envName])
|
|
|
|
return discoverEnv[envName];
|
|
|
|
else
|
|
|
|
return '';
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
2011-04-06 02:23:43 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Set the input value on discovery page
|
2011-04-06 02:23:43 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param envName Value name (discoverEnv key)
|
|
|
|
* @param envValue Value
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function setDiscoverEnv(envName, envValue) {
|
|
|
|
if (envName)
|
|
|
|
discoverEnv[envName] = envValue;
|
2011-04-06 02:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Delete the input value on discovery page
|
2011-04-06 02:23:43 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param envName Value name (discoverEnv's key)
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function removeDiscoverEnv(envName) {
|
|
|
|
if (discoverEnv[envName])
|
|
|
|
delete discoverEnv[envName];
|
2011-04-06 02:23:43 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Expand the noderange into node names
|
2010-11-24 06:10:07 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param nodeRange Node range
|
|
|
|
* @return Array of node names
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function expandNR(nodeRange) {
|
|
|
|
var retArray = new Array();
|
|
|
|
var tempResult;
|
|
|
|
if ('' == nodeRange)
|
|
|
|
return retArray;
|
|
|
|
|
|
|
|
tempResult = nodeRange.match(/(.*?)\[(.*?)\](.*)/);
|
|
|
|
if (null != tempResult) {
|
|
|
|
var parts = tempResult[2].split('-');
|
|
|
|
if (2 > parts.length)
|
|
|
|
return retArray;
|
|
|
|
|
|
|
|
var len = parts[0].length;
|
|
|
|
for (var i = parts[0]; i <= parts[1]; i++) {
|
|
|
|
var ts = i.toString();
|
|
|
|
if (ts.length < len)
|
|
|
|
ts = "000000".substring(0, (len - ts.length)) + ts;
|
|
|
|
|
|
|
|
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+)$/);
|
|
|
|
if (2 > begin) {
|
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var end = tempArray[1].match(/^(\D+)(\d+)$/);
|
|
|
|
if (2 > end) {
|
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (begin[1] != end[1]) {
|
|
|
|
retArray.push(nodeRange);
|
|
|
|
return retArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
var prefix = begin[1];
|
|
|
|
var len = begin[2].length;
|
|
|
|
for (var i = begin[2]; i <= end[2]; i++) {
|
|
|
|
var ts = i.toString();
|
|
|
|
if (ts.length < len)
|
|
|
|
ts = "000000".substring(0, (len - ts.length)) + ts;
|
|
|
|
retArray.push(prefix + ts);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retArray;
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-06 02:23:43 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Collect all input values from the page
|
2011-04-06 02:23:43 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @return True if this step is correct and can go to the next page, false if this step contains error
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function collectInputValue() {
|
|
|
|
$('#discoverContentDiv input[type=text]').each(function() {
|
|
|
|
var name = $(this).attr('name');
|
|
|
|
var value = $(this).attr('value');
|
|
|
|
if ('' != value)
|
|
|
|
setDiscoverEnv(name, value);
|
|
|
|
else
|
|
|
|
removeDiscoverEnv(name);
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
2011-04-06 02:23:43 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Verify the IP address
|
2011-12-31 06:46:13 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param ip IP address
|
|
|
|
* @return True if IP address is valid, false otherwise
|
2011-12-31 06:46:13 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function verifyIp(ip) {
|
2011-12-31 06:46:13 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Transalate IP into decimal
|
2011-12-31 06:46:13 +00:00
|
|
|
*
|
2012-05-04 14:45:17 +00:00
|
|
|
* @param ip IP address
|
|
|
|
* @return Decimal type for IP address
|
2011-12-31 06:46:13 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function ip2Decimal(ip) {
|
2012-03-14 19:23:51 +00:00
|
|
|
if (!verifyIp(ip))
|
2011-12-31 06:46:13 +00:00
|
|
|
return 0;
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
var retIp = 0;
|
|
|
|
var tempArray = ip.split('.');
|
2012-05-04 14:45:17 +00:00
|
|
|
for (var i = 0; i < 4; i++) {
|
2011-12-31 06:46:13 +00:00
|
|
|
retIp = (retIp << 8) | parseInt(tempArray[i]);
|
|
|
|
}
|
2012-05-04 14:45:17 +00:00
|
|
|
|
|
|
|
// Change the int into unsigned int type
|
2011-12-31 06:46:13 +00:00
|
|
|
retIp = retIp >>> 0;
|
|
|
|
return retIp;
|
|
|
|
}
|
2012-03-14 19:23:51 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Calculate the ending IP address from the starting IP address and the IP range number.
|
2011-12-31 06:46:13 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function calcEndIp(ipStart, num) {
|
2011-12-31 06:46:13 +00:00
|
|
|
var sum = 0;
|
|
|
|
var tempNum = Number(num);
|
|
|
|
var temp = /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
|
|
|
|
var ipArray = temp.exec(ipStart);
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray.shift();
|
|
|
|
sum = Number(ipArray[3]) + tempNum;
|
2012-05-04 14:45:17 +00:00
|
|
|
if (sum <= 254) {
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray[3] = sum;
|
|
|
|
return (ipArray.join('.'));
|
|
|
|
}
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray[3] = sum % 254;
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
sum = Number(ipArray[2]) + parseInt(sum / 254);
|
2012-05-04 14:45:17 +00:00
|
|
|
if (sum <= 255) {
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray[2] = sum;
|
|
|
|
return (ipArray.join('.'));
|
|
|
|
}
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray[2] = sum % 255;
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
sum = Number(ipArray[1]) + parseInt(sum / 255);
|
2012-05-04 14:45:17 +00:00
|
|
|
if (sum <= 255) {
|
2011-12-31 06:46:13 +00:00
|
|
|
ipArray[1] = sum;
|
|
|
|
return (ipArray.join('.'));
|
|
|
|
}
|
2012-05-04 14:45:17 +00:00
|
|
|
|
2011-12-31 06:46:13 +00:00
|
|
|
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
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Step 1: Show the wizard's function platform selector (System p or System x)
|
2010-11-24 06:10:07 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function initSelectPlatform() {
|
|
|
|
var type = '';
|
|
|
|
|
|
|
|
$('#discoverContentDiv').empty();
|
|
|
|
$('.tooltip').remove();
|
|
|
|
|
|
|
|
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'
|
|
|
|
+ '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.';
|
|
|
|
var info = createInfoBar(infoMsg);
|
|
|
|
selectPlatform.append(info);
|
|
|
|
|
|
|
|
var hwList = $('<ol>Platforms available:</ol>');
|
2012-07-23 10:28:14 +00:00
|
|
|
hwList.append('<li><input type="radio" name="platform" disabled="true" id="idataplex"><label>iDataPlex</label></input></li>');
|
2012-05-04 14:45:17 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
$('#discoverContentDiv').append(selectPlatform);
|
|
|
|
|
|
|
|
if (getDiscoverEnv('machineType'))
|
|
|
|
type = getDiscoverEnv('machineType');
|
|
|
|
else
|
|
|
|
type = 'ih';
|
|
|
|
|
|
|
|
$('#discoverContentDiv #' + type).attr('checked', 'checked');
|
|
|
|
createDiscoverButtons();
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-06 02:23:43 +00:00
|
|
|
/**
|
|
|
|
* Step 1: Get the platform type
|
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
function getPlatform() {
|
|
|
|
var radioValue = $('#discoverContentDiv :checked').attr('id');
|
|
|
|
var platformObj = null;
|
|
|
|
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;
|
2011-04-06 02:23:43 +00:00
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2010-11-24 06:10:07 +00:00
|
|
|
/**
|
2012-05-04 14:45:17 +00:00
|
|
|
* Last step: Complete
|
2011-04-06 02:23:43 +00:00
|
|
|
*/
|
2012-05-04 14:45:17 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
createDiscoverButtons();
|
2010-11-24 06:10:07 +00:00
|
|
|
}
|