2010-11-04 07:07:53 +00:00
|
|
|
var bpaList;
|
|
|
|
var fspList;
|
|
|
|
var lparList;
|
2010-11-08 07:19:05 +00:00
|
|
|
var nodeList;
|
2010-11-12 07:46:42 +00:00
|
|
|
var selectNode = new Object();
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
/**
|
2010-11-08 07:19:05 +00:00
|
|
|
* extract all nodes userful data into a hash, which is used for creating graphical
|
2010-11-04 07:07:53 +00:00
|
|
|
*
|
|
|
|
* @param data: the response from xcat command "nodels all nodetype.nodetype ppc.parent ..."
|
2010-11-08 07:19:05 +00:00
|
|
|
*
|
2010-11-04 07:07:53 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2010-11-08 07:19:05 +00:00
|
|
|
function extractGraphicalData(data){
|
2010-11-04 07:07:53 +00:00
|
|
|
var nodes = data.rsp;
|
2010-11-08 07:19:05 +00:00
|
|
|
nodeList = new Object();
|
2010-11-04 07:07:53 +00:00
|
|
|
|
|
|
|
//extract useful info into tempList
|
|
|
|
for (var i = 0; i < nodes.length; i++){
|
|
|
|
var nodeName = nodes[i][0];
|
2010-11-08 07:19:05 +00:00
|
|
|
if (undefined == nodeList[nodeName]){
|
|
|
|
nodeList[nodeName] = new Object();
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(nodes[i][2]){
|
|
|
|
case 'nodetype.nodetype': {
|
2010-11-08 07:19:05 +00:00
|
|
|
nodeList[nodeName]['type'] = nodes[i][1];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'ppc.parent' : {
|
2010-11-08 07:19:05 +00:00
|
|
|
nodeList[nodeName]['parent'] = nodes[i][1];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'nodelist.status': {
|
2010-11-08 07:19:05 +00:00
|
|
|
nodeList[nodeName]['status'] = nodes[i][1];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'vpd.mtm': {
|
2010-11-08 07:19:05 +00:00
|
|
|
nodeList[nodeName]['mtm'] = nodes[i][1];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-12 07:46:42 +00:00
|
|
|
break;
|
|
|
|
case 'nodehm.mgt': {
|
|
|
|
nodeList[nodeName]['mgt'] = nodes[i][1];
|
|
|
|
}
|
|
|
|
break;
|
2010-11-04 07:07:53 +00:00
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createPhysicalLayout(data){
|
|
|
|
bpaList = new Object();
|
|
|
|
fspList = new Object();
|
|
|
|
lparList = new Object();
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2010-11-08 07:19:05 +00:00
|
|
|
$('#graphTab').empty();
|
|
|
|
for (var temp in data.rsp){
|
|
|
|
var nodeName = data.rsp[temp];
|
|
|
|
nodeName = nodeName.substring(0, nodeName.indexOf(' '));
|
|
|
|
if ('' == nodeName){
|
|
|
|
continue;
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
fillList(nodeName);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
createGraphical(bpaList, fspList, $('#graphTab'));
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 07:19:05 +00:00
|
|
|
function fillList(nodeName){
|
|
|
|
var parentName = nodeList[nodeName]['parent'];
|
|
|
|
var mtm = nodeList[nodeName]['mtm'];
|
|
|
|
var status = nodeList[nodeName]['status'];
|
|
|
|
|
|
|
|
switch(nodeList[nodeName]['type']){
|
|
|
|
case 'bpa': {
|
|
|
|
if (undefined == bpaList[nodeName]){
|
|
|
|
bpaList[nodeName] = new Array();
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
break;
|
|
|
|
case 'lpar,osi': {
|
|
|
|
if ('' == parentName){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undefined == fspList[parentName]){
|
|
|
|
fillList(parentName);
|
|
|
|
}
|
|
|
|
|
|
|
|
fspList[parentName]['children'].push(nodeName);
|
|
|
|
lparList[nodeName] = status;
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
break;
|
|
|
|
case 'fsp': {
|
|
|
|
if (undefined != fspList[nodeName]){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fspList[nodeName] = new Array();
|
|
|
|
fspList[nodeName]['children'] = new Array();
|
|
|
|
fspList[nodeName]['mtm'] = mtm;
|
|
|
|
|
|
|
|
if ('' == parentName){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undefined == bpaList[parentName]){
|
|
|
|
fillList(parentName);
|
|
|
|
}
|
|
|
|
|
|
|
|
bpaList[parentName].push(nodeName);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* create the physical graphical layout
|
|
|
|
*
|
|
|
|
* @param bpa : all bpa and there related fsps
|
|
|
|
* fsp : all fsp and there related lpars
|
|
|
|
* fspinfo : all fsps' hardwareinfo
|
|
|
|
* area: the element to append graphical layout
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
function createGraphical(bpa, fsp, area){
|
|
|
|
var usedFsp = new Object();
|
2010-11-08 07:19:05 +00:00
|
|
|
var graphTable = $('<table id="graphTable" style="border-color: transparent;"><tbody></tbody></table>');
|
2010-11-04 07:07:53 +00:00
|
|
|
var elementNum = 0;
|
|
|
|
var row;
|
|
|
|
for (var bpaName in bpa){
|
|
|
|
if (0 == elementNum % 3){
|
|
|
|
row = $('<tr></tr>');
|
|
|
|
graphTable.append(row);
|
|
|
|
}
|
|
|
|
elementNum ++;
|
2010-11-08 07:19:05 +00:00
|
|
|
var td = $('<td style="padding:0;border-color: transparent;"></td>');
|
2010-11-04 07:07:53 +00:00
|
|
|
var frameDiv = $('<div class="frameDiv"></div>');
|
|
|
|
frameDiv.append('<div style="height:27px;">' + bpaName + '</div>');
|
|
|
|
for (var fspIndex in bpa[bpaName]){
|
|
|
|
var fspName = bpa[bpaName][fspIndex];
|
|
|
|
usedFsp[fspName] = 1;
|
|
|
|
|
2010-11-05 06:38:38 +00:00
|
|
|
frameDiv.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp));
|
|
|
|
frameDiv.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp));
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
td.append(frameDiv);
|
|
|
|
row.append(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
//find the single fsp and sort descend by units
|
|
|
|
var singleFsp = new Array();
|
|
|
|
for (var fspName in fsp){
|
|
|
|
if (usedFsp[fspName])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
singleFsp.push([fspName, fsp[fspName]['mtm']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
singleFsp.sort(function(a, b){
|
|
|
|
var unitNumA = 4;
|
|
|
|
var unitNumB = 4;
|
|
|
|
if (hardwareInfo[a[1]]){
|
|
|
|
unitNumA = hardwareInfo[a[1]][1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hardwareInfo[b[1]]){
|
|
|
|
unitNumB = hardwareInfo[b[1]][1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return (unitNumB - unitNumA);
|
|
|
|
});
|
|
|
|
|
|
|
|
elementNum = 0;
|
|
|
|
for (var fspIndex in singleFsp){
|
|
|
|
var fspName = singleFsp[fspIndex][0];
|
|
|
|
if (0 == elementNum % 3){
|
|
|
|
row = $('<tr></tr>');
|
|
|
|
graphTable.append(row);
|
|
|
|
}
|
|
|
|
elementNum ++;
|
|
|
|
|
2010-11-08 07:19:05 +00:00
|
|
|
var td = $('<td style="vertical-align:top;border-color: transparent;"></td>');
|
2010-11-05 06:38:38 +00:00
|
|
|
td.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp));
|
|
|
|
td.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp));
|
2010-11-04 07:07:53 +00:00
|
|
|
row.append(td);
|
|
|
|
}
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
var selectNodeDiv = $('<div id="selectNodeDiv" style="margin: 20px;"></div>');
|
2010-11-04 07:07:53 +00:00
|
|
|
var temp = 0;
|
2010-11-12 07:46:42 +00:00
|
|
|
for (var i in selectNode){
|
2010-11-04 07:07:53 +00:00
|
|
|
temp ++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//there is not selected lpars, show the info bar
|
|
|
|
if (0 == temp){
|
2010-11-16 16:32:56 +00:00
|
|
|
area.append(createInfoBar('Hover CEC and select lpars to do operations.'));
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
//show selected lpars
|
|
|
|
else{
|
2010-11-12 07:46:42 +00:00
|
|
|
updateSelectNodeDiv();
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
|
|
|
|
//add buttons
|
2010-11-08 08:09:12 +00:00
|
|
|
area.append(createActionMenu());
|
2010-11-12 07:46:42 +00:00
|
|
|
area.append(selectNodeDiv);
|
2010-11-08 07:19:05 +00:00
|
|
|
area.append(graphTable);
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2010-11-05 06:38:38 +00:00
|
|
|
$('.tooltip input[type = checkbox]').bind('click', function(){
|
|
|
|
var lparName = $(this).attr('name');
|
|
|
|
if ('' == lparName){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (true == $(this).attr('checked')){
|
2010-11-12 07:46:42 +00:00
|
|
|
selectNode[lparName] = 1;
|
2010-11-05 06:38:38 +00:00
|
|
|
$('#graphTable [name=' + lparName + ']').css('border-color', 'aqua');
|
|
|
|
}
|
|
|
|
else{
|
2010-11-12 07:46:42 +00:00
|
|
|
delete selectNode[lparName];
|
2010-11-08 07:19:05 +00:00
|
|
|
$('#graphTable [name=' + lparName + ']').css('border-color', '#BDBDBD');
|
2010-11-05 06:38:38 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
updateSelectNodeDiv();
|
2010-11-05 06:38:38 +00:00
|
|
|
});
|
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
$('.fspDiv2, .fspDiv4, .fspDiv42').tooltip({
|
2010-11-08 07:19:05 +00:00
|
|
|
position: "top center",
|
|
|
|
relative : true,
|
|
|
|
offset : [20, 40],
|
|
|
|
effect: "fade"
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-09 07:34:31 +00:00
|
|
|
$('.tooltip a').bind('click', function(){
|
|
|
|
var lparName = $(this).html();
|
|
|
|
$('#nodesDataTable #' + lparName).trigger('click');
|
|
|
|
});
|
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
$('.fspDiv2, .fspDiv4, .fspDiv42').bind('click', function(){
|
|
|
|
var fspName = $(this).attr('value');
|
|
|
|
showSelectDialog(fspList[fspName]['children']);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* show the fsp's information in a dialog
|
|
|
|
*
|
|
|
|
* @param fspName : fsp's name
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
function showSelectDialog(lpars){
|
|
|
|
var diaDiv = $('<div class="tab" title=Select Lpars"></div>');
|
|
|
|
|
|
|
|
if (0 == lpars.length){
|
2010-11-08 07:19:05 +00:00
|
|
|
diaDiv.append(createInfoBar('There is not any lpars be selected(defined).'));
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
//add the dialog content
|
2010-11-12 07:46:42 +00:00
|
|
|
var selectTable = $('<table id="selectNodeTable"><tbody></tbody></table>');
|
2010-11-04 07:07:53 +00:00
|
|
|
selectTable.append('<tr><th><input type="checkbox" onclick="selectAllLpars($(this))"></input></th><th>Name</th><th>Status</th></tr>');
|
|
|
|
for (var lparIndex in lpars){
|
|
|
|
var row = $('<tr></tr>');
|
|
|
|
var lparName = lpars[lparIndex];
|
|
|
|
var color = statusMap(lparList[lparName]);
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
if (selectNode[lparName]){
|
2010-11-05 06:38:38 +00:00
|
|
|
row.append('<td><input type="checkbox" checked="checked" name="' + lparName + '"></input></td>');
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
else{
|
2010-11-05 06:38:38 +00:00
|
|
|
row.append('<td><input type="checkbox" name="' + lparName + '"></input></td>');
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
row.append('<td>' + lparName + '</td>');
|
|
|
|
row.append('<td style="background-color:' + color + ';">' + lparList[lparName] + '</td>');
|
|
|
|
selectTable.append(row);
|
|
|
|
}
|
|
|
|
diaDiv.append(selectTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
diaDiv.dialog({
|
|
|
|
modal: true,
|
|
|
|
width: 400,
|
|
|
|
close: function(event, ui){
|
|
|
|
$(this).remove();
|
|
|
|
},
|
|
|
|
buttons: {
|
|
|
|
cancel : function(){
|
|
|
|
$(this).dialog('close');
|
|
|
|
},
|
|
|
|
ok : function(){
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeTable input[type=checkbox]').each(function(){
|
2010-11-05 06:38:38 +00:00
|
|
|
var lparName = $(this).attr('name');
|
2010-11-04 07:07:53 +00:00
|
|
|
if ('' == lparName){
|
|
|
|
//continue
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (true == $(this).attr('checked')){
|
2010-11-12 07:46:42 +00:00
|
|
|
selectNode[lparName] = 1;
|
2010-11-05 06:38:38 +00:00
|
|
|
$('#graphTable [name=' + lparName + ']').css('border-color', 'aqua');
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
else{
|
2010-11-12 07:46:42 +00:00
|
|
|
delete selectNode[lparName];
|
|
|
|
$('#graphTable [name=' + lparName + ']').css('border-color', '#BDBDBD');
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
});
|
2010-11-12 07:46:42 +00:00
|
|
|
updateSelectNodeDiv();
|
2010-11-04 07:07:53 +00:00
|
|
|
$(this).dialog('close');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-12 07:46:42 +00:00
|
|
|
* update the lpars' background in cec, lpars area and selectNode
|
2010-11-04 07:07:53 +00:00
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
**/
|
2010-11-12 07:46:42 +00:00
|
|
|
function updateSelectNodeDiv(){
|
2010-11-04 07:07:53 +00:00
|
|
|
var temp = 0;
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeDiv').empty();
|
2010-11-08 07:19:05 +00:00
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
//add buttons
|
2010-11-08 07:19:05 +00:00
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeDiv').append('Lpars: ');
|
|
|
|
for(var lparName in selectNode){
|
|
|
|
$('#selectNodeDiv').append(lparName + ' ');
|
2010-11-04 07:07:53 +00:00
|
|
|
temp ++;
|
|
|
|
if (6 < temp){
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeDiv').append('...');
|
2010-11-04 07:07:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var reselectButton = createButton('Reselect');
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeDiv').append(reselectButton);
|
2010-11-04 07:07:53 +00:00
|
|
|
reselectButton.bind('click', function(){
|
2010-11-12 07:46:42 +00:00
|
|
|
reselectNodes();
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the action menu
|
|
|
|
*
|
|
|
|
* @param getNodesFunction
|
|
|
|
* the function that can find selected nodes name
|
|
|
|
* @return
|
|
|
|
* action menu object
|
|
|
|
*/
|
|
|
|
function createActionMenu(){
|
|
|
|
// Create action bar
|
|
|
|
var actionBar = $('<div class="actionBar"></div>');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The following actions are available to perform against a given node:
|
|
|
|
* power, clone, delete, unlock, and advanced
|
|
|
|
*/
|
|
|
|
var powerLnk = $('<a>Power</a>');
|
2010-11-12 07:46:42 +00:00
|
|
|
//Power on
|
2010-11-04 07:07:53 +00:00
|
|
|
var powerOnLnk = $('<a>Power on</a>');
|
|
|
|
powerOnLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
2010-11-04 07:07:53 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'rpower',
|
|
|
|
tgt : tgtNodes,
|
|
|
|
args : 'on',
|
|
|
|
msg : ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Power off
|
2010-11-04 07:07:53 +00:00
|
|
|
var powerOffLnk = $('<a>Power off</a>');
|
|
|
|
powerOffLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
2010-11-04 07:07:53 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'rpower',
|
|
|
|
tgt : tgtNodes,
|
|
|
|
args : 'off',
|
|
|
|
msg : ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Clone
|
2010-11-04 07:07:53 +00:00
|
|
|
var cloneLnk = $('<a>Clone</a>');
|
|
|
|
cloneLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
for (var name in selectNode) {
|
|
|
|
var mgt = nodeList[name]['mgt'];
|
2010-11-04 07:07:53 +00:00
|
|
|
|
|
|
|
// Create an instance of the plugin
|
|
|
|
var plugin;
|
|
|
|
switch(mgt) {
|
|
|
|
case "blade":
|
|
|
|
plugin = new bladePlugin();
|
|
|
|
break;
|
|
|
|
case "fsp":
|
|
|
|
plugin = new fspPlugin();
|
|
|
|
break;
|
|
|
|
case "hmc":
|
|
|
|
plugin = new hmcPlugin();
|
|
|
|
break;
|
|
|
|
case "ipmi":
|
|
|
|
plugin = new ipmiPlugin();
|
|
|
|
break;
|
|
|
|
case "ivm":
|
|
|
|
plugin = new ivmPlugin();
|
|
|
|
break;
|
|
|
|
case "zvm":
|
|
|
|
plugin = new zvmPlugin();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
plugin.loadClonePage(name);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Delete
|
2010-11-04 07:07:53 +00:00
|
|
|
var deleteLnk = $('<a>Delete</a>');
|
|
|
|
deleteLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
deleteNode(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Unlock
|
2010-11-04 07:07:53 +00:00
|
|
|
var unlockLnk = $('<a>Unlock</a>');
|
|
|
|
unlockLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadUnlockPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Run script
|
2010-11-04 07:07:53 +00:00
|
|
|
var scriptLnk = $('<a>Run script</a>');
|
|
|
|
scriptLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadScriptPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Update node
|
2010-11-04 07:07:53 +00:00
|
|
|
var updateLnk = $('<a>Update</a>');
|
|
|
|
updateLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadUpdatenodePage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Set boot state
|
2010-11-04 07:07:53 +00:00
|
|
|
var setBootStateLnk = $('<a>Set boot state</a>');
|
|
|
|
setBootStateLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadNodesetPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Boot to network
|
2010-11-04 07:07:53 +00:00
|
|
|
var boot2NetworkLnk = $('<a>Boot to network</a>');
|
|
|
|
boot2NetworkLnk.bind('click', function(event) {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadNetbootPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
//Open the Rcons page
|
2010-11-04 07:07:53 +00:00
|
|
|
var rcons = $('<a>Open Rcons</a>');
|
|
|
|
rcons.bind('click', function(event){
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
2010-11-04 07:07:53 +00:00
|
|
|
if (tgtNodes) {
|
|
|
|
loadRconsPage(tgtNodes);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var advancedLnk = $('<a>Advanced</a>');
|
|
|
|
|
|
|
|
// Power actions
|
|
|
|
var powerActions = [ powerOnLnk, powerOffLnk ];
|
|
|
|
var powerActionMenu = createMenu(powerActions);
|
|
|
|
|
|
|
|
// Advanced actions
|
|
|
|
var advancedActions;
|
|
|
|
advancedActions = [ boot2NetworkLnk, scriptLnk, setBootStateLnk, updateLnk, rcons ];
|
|
|
|
var advancedActionMenu = createMenu(advancedActions);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an action menu
|
|
|
|
*/
|
|
|
|
var actionsDIV = $('<div></div>');
|
|
|
|
var actions = [ [ powerLnk, powerActionMenu ], cloneLnk, deleteLnk, unlockLnk, [ advancedLnk, advancedActionMenu ] ];
|
|
|
|
var actionMenu = createMenu(actions);
|
|
|
|
actionMenu.superfish();
|
|
|
|
actionsDIV.append(actionMenu);
|
|
|
|
actionBar.append(actionsDIV);
|
|
|
|
|
|
|
|
return actionBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the physical graphical layout
|
|
|
|
*
|
|
|
|
* @param bpaName : fsp's key
|
|
|
|
* fsp : all fsp and there related lpars
|
|
|
|
* fspinfo : all fsps' hardwareinfo
|
|
|
|
* @return
|
2010-11-05 06:38:38 +00:00
|
|
|
*
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
|
|
|
function createFspDiv(fspName, mtm, fsp){
|
|
|
|
//create fsp title
|
|
|
|
var lparStatusRow = '';
|
|
|
|
|
|
|
|
for (var lparIndex in fsp[fspName]['children']){
|
2010-11-08 07:19:05 +00:00
|
|
|
//show 8 lpars on one cec at most.
|
|
|
|
if (lparIndex >= 8){
|
|
|
|
break;
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
var lparName = fsp[fspName]['children'][lparIndex];
|
|
|
|
var color = statusMap(lparList[lparName]);
|
2010-11-08 07:19:05 +00:00
|
|
|
lparStatusRow += '<td class="lparStatus" style="background-color:' + color + ';color:' + color + ';padding: 0px;font-size:1;border-width: 1px;border-style: solid;" name="' + lparName + '">1</td>';
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//select the backgroud
|
|
|
|
var divClass = '';
|
|
|
|
if (hardwareInfo[mtm][1]){
|
|
|
|
divClass += 'fspDiv' + hardwareInfo[mtm][1];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
divClass += 'fspDiv4';
|
|
|
|
}
|
|
|
|
|
|
|
|
//create return value
|
2010-11-05 06:38:38 +00:00
|
|
|
var retHtml = '<div value="' + fspName + '" class="' + divClass + '">';
|
|
|
|
retHtml += '<div class="lparDiv"><table><tbody><tr>' + lparStatusRow + '</tr></tbody></table></div></div>';
|
2010-11-04 07:07:53 +00:00
|
|
|
return retHtml;
|
|
|
|
}
|
|
|
|
|
2010-11-05 06:38:38 +00:00
|
|
|
/**
|
|
|
|
* create the physical graphical fsps' help witch could select the lpars.
|
|
|
|
*
|
|
|
|
* @param bpaName : fsp's key
|
|
|
|
* fsp : all fsp and there related lpars
|
|
|
|
* fspinfo : all fsps' hardwareinfo
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function createFspTip(fspName, mtm, fsp){
|
|
|
|
var tip = $('<div class="tooltip"></div>');
|
|
|
|
var tempTable = $('<table><tbody></tbody></table>');
|
|
|
|
if (hardwareInfo[mtm]){
|
|
|
|
tip.append('<h3>' + fspName + '(' + hardwareInfo[mtm][0] + ')</h3><br/>');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
tip.append('<h3>' + fspName + '</h3><br/>');
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var lparIndex in fsp[fspName]['children']){
|
|
|
|
var lparName = fsp[fspName]['children'][lparIndex];
|
|
|
|
var color = statusMap(lparList[lparName]);
|
|
|
|
var row = '<tr><td><input type="checkbox" name="' + lparName + '"></td>';
|
2010-11-09 07:34:31 +00:00
|
|
|
row += '<td style="color:#fff"><a>'+ lparName + '</a></td>';
|
2010-11-08 07:19:05 +00:00
|
|
|
row += '<td style="background-color:' + color + ';color:#fff">' + lparList[lparName] + '</td></tr>';
|
2010-11-05 06:38:38 +00:00
|
|
|
tempTable.append(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
tip.append(tempTable);
|
|
|
|
return tip;
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
/**
|
|
|
|
* map the lpar's status into a color
|
|
|
|
*
|
|
|
|
* @param status : lpar's status in nodelist table
|
|
|
|
|
|
|
|
* @return
|
|
|
|
* corresponding color name
|
|
|
|
*/
|
|
|
|
function statusMap(status){
|
|
|
|
var color = 'gainsboro';
|
|
|
|
|
|
|
|
switch(status){
|
|
|
|
case 'alive':
|
|
|
|
case 'ready':
|
|
|
|
case 'pbs':
|
|
|
|
case 'sshd':
|
|
|
|
case 'booting':{
|
|
|
|
color = 'green';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'noping':
|
|
|
|
case 'unreachable':{
|
|
|
|
color = 'red';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'ping':{
|
|
|
|
color = 'yellow';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select all lpars checkbox in the dialog
|
|
|
|
*
|
|
|
|
* @param
|
|
|
|
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function selectAllLpars(checkbox){
|
|
|
|
var temp = checkbox.attr('checked');
|
2010-11-12 07:46:42 +00:00
|
|
|
$('#selectNodeTable input[type = checkbox]').attr('checked', temp);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-11-12 07:46:42 +00:00
|
|
|
* export all lpars' name from selectNode
|
2010-11-04 07:07:53 +00:00
|
|
|
*
|
|
|
|
* @param
|
|
|
|
|
|
|
|
* @return lpars' string
|
|
|
|
*
|
|
|
|
*/
|
2010-11-12 07:46:42 +00:00
|
|
|
function getSelectNodes(){
|
2010-11-04 07:07:53 +00:00
|
|
|
var ret = '';
|
2010-11-12 07:46:42 +00:00
|
|
|
for (var lparName in selectNode){
|
2010-11-04 07:07:53 +00:00
|
|
|
ret += lparName + ',';
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.substring(0, ret.length-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* show all lpars' for users to delete
|
|
|
|
*
|
|
|
|
* @param
|
|
|
|
|
|
|
|
* @return
|
|
|
|
*/
|
2010-11-12 07:46:42 +00:00
|
|
|
function reselectNodes(){
|
2010-11-04 07:07:53 +00:00
|
|
|
var temp = new Array();
|
|
|
|
|
2010-11-12 07:46:42 +00:00
|
|
|
for (var lparName in selectNode){
|
2010-11-04 07:07:53 +00:00
|
|
|
temp.push(lparName);
|
|
|
|
}
|
|
|
|
|
|
|
|
showSelectDialog(temp);
|
|
|
|
}
|