2010-11-04 07:07:53 +00:00
|
|
|
var bpaList;
|
|
|
|
var fspList;
|
|
|
|
var lparList;
|
2011-10-31 09:37:54 +00:00
|
|
|
var bladeList;
|
2011-01-17 03:01:46 +00:00
|
|
|
var graphicalNodeList;
|
2010-12-03 09:16:58 +00:00
|
|
|
var selectNode;
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-03-01 14:52:52 +00:00
|
|
|
/**
|
|
|
|
* get all nodes useful attributes from remote server.
|
|
|
|
*
|
|
|
|
* @param dataTypeIndex: the index in Array graphicalDataType, which contains attributes we need.
|
|
|
|
* attrNullNode: the target node list for this attribute
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
2011-09-28 08:49:45 +00:00
|
|
|
function initGraphicalData(){
|
|
|
|
$('#graphTab').append(createLoader());
|
2011-01-17 03:01:46 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
2011-09-28 08:49:45 +00:00
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'graph',
|
|
|
|
msg : ''
|
2011-01-17 03:01:46 +00:00
|
|
|
},
|
2011-09-28 08:49:45 +00:00
|
|
|
success: function(data){
|
|
|
|
if(!data.rsp[0]){
|
|
|
|
return;
|
2011-01-18 07:51:07 +00:00
|
|
|
}
|
2011-09-28 08:49:45 +00:00
|
|
|
extractGraphicalData(data.rsp[0]);
|
|
|
|
getNodesAndDraw();
|
2011-01-18 07:51:07 +00:00
|
|
|
}
|
2011-01-17 03:01:46 +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 ..."
|
2011-03-01 14:52:52 +00:00
|
|
|
* @return nodes list for next time query
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
2010-11-08 07:19:05 +00:00
|
|
|
function extractGraphicalData(data){
|
2011-09-28 08:49:45 +00:00
|
|
|
var nodes = data.split(';');
|
|
|
|
var attrs;
|
|
|
|
var nodename;
|
2010-11-04 07:07:53 +00:00
|
|
|
//extract useful info into tempList
|
|
|
|
for (var i = 0; i < nodes.length; i++){
|
2011-09-28 08:49:45 +00:00
|
|
|
attrs = nodes[i].split(':');
|
|
|
|
nodename = attrs[0];
|
|
|
|
if (undefined == graphicalNodeList[nodename]){
|
|
|
|
graphicalNodeList[nodename] = new Object();
|
2011-04-28 08:00:00 +00:00
|
|
|
}
|
2011-10-31 09:37:54 +00:00
|
|
|
graphicalNodeList[nodename]['type'] = attrs[1].toLowerCase();
|
2011-09-28 08:49:45 +00:00
|
|
|
switch(attrs[1].toLowerCase()){
|
|
|
|
case 'cec':
|
|
|
|
case 'frame':
|
|
|
|
case 'lpar':
|
|
|
|
case 'lpar,osi':
|
|
|
|
case 'osi,lpar':
|
|
|
|
graphicalNodeList[nodename]['parent'] = attrs[2];
|
|
|
|
graphicalNodeList[nodename]['mtm'] = attrs[3];
|
|
|
|
graphicalNodeList[nodename]['status'] = attrs[4];
|
|
|
|
break;
|
|
|
|
case 'blade':
|
|
|
|
graphicalNodeList[nodename]['mpa'] = attrs[2];
|
|
|
|
graphicalNodeList[nodename]['unit'] = attrs[3];
|
|
|
|
graphicalNodeList[nodename]['status'] = attrs[4];
|
|
|
|
break;
|
|
|
|
case 'systemx':
|
|
|
|
graphicalNodeList[nodename]['rack'] = attrs[2];
|
|
|
|
graphicalNodeList[nodename]['unit'] = attrs[3];
|
|
|
|
graphicalNodeList[nodename]['mtm'] = attrs[4];
|
|
|
|
graphicalNodeList[nodename]['status'] = attrs[5];
|
|
|
|
break;
|
|
|
|
default:
|
2010-11-04 07:07:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-03-01 14:52:52 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 03:01:46 +00:00
|
|
|
function createPhysicalLayout(nodeList){
|
2011-01-18 07:51:07 +00:00
|
|
|
var flag = false;
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-01-28 03:16:48 +00:00
|
|
|
//when the graphical layout is shown, do not need to redraw
|
|
|
|
if (1 < $('#graphTab').children().length){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-18 07:51:07 +00:00
|
|
|
//save the new selected nodes.
|
2011-04-16 14:40:15 +00:00
|
|
|
if (graphicalNodeList){
|
2011-01-18 07:51:07 +00:00
|
|
|
for(var i in graphicalNodeList){
|
|
|
|
flag = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-31 02:28:59 +00:00
|
|
|
bpaList = new Object();
|
|
|
|
fspList = new Object();
|
|
|
|
lparList = new Object();
|
2011-10-31 09:37:54 +00:00
|
|
|
bladeList = new Object();
|
2011-08-31 02:28:59 +00:00
|
|
|
selectNode = new Object();
|
|
|
|
|
2011-01-18 07:51:07 +00:00
|
|
|
//there is not graphical data, get the info now
|
|
|
|
if (!flag){
|
|
|
|
graphicalNodeList = new Object();
|
2011-09-28 08:49:45 +00:00
|
|
|
initGraphicalData();
|
2011-01-18 07:51:07 +00:00
|
|
|
}
|
|
|
|
else{
|
2011-09-28 08:49:45 +00:00
|
|
|
getNodesAndDraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNodesAndDraw(){
|
|
|
|
var groupname = $.cookie('selectgrouponnodes');
|
|
|
|
$.ajax({
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'nodels',
|
|
|
|
tgt : groupname,
|
|
|
|
args : '',
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
success : function(data){
|
|
|
|
for (var temp in data.rsp){
|
|
|
|
var nodeName = data.rsp[temp][0];
|
|
|
|
if ('' == nodeName){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
fillList(nodeName);
|
2011-01-18 07:51:07 +00:00
|
|
|
}
|
2011-09-28 08:49:45 +00:00
|
|
|
$('#graphTab').empty();
|
2011-10-31 09:37:54 +00:00
|
|
|
createGraphical();
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2011-09-28 08:49:45 +00:00
|
|
|
});
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
2011-08-31 02:28:59 +00:00
|
|
|
function fillList(nodeName, defaultnodetype){
|
|
|
|
var parentName = '';
|
|
|
|
var mtm = '';
|
|
|
|
var status = '';
|
|
|
|
var nodetype = '';
|
2011-10-31 09:37:54 +00:00
|
|
|
var mpa = '';
|
|
|
|
var unit = '';
|
2011-08-31 02:28:59 +00:00
|
|
|
if (!graphicalNodeList[nodeName]){
|
|
|
|
parentName = '';
|
|
|
|
mtm = '';
|
|
|
|
status = '';
|
|
|
|
nodetype = defaultnodetype;
|
|
|
|
}
|
|
|
|
else{
|
2011-10-31 09:37:54 +00:00
|
|
|
status = graphicalNodeList[nodeName]['status'];
|
2011-08-31 02:28:59 +00:00
|
|
|
nodetype = graphicalNodeList[nodeName]['type'];
|
2011-10-31 09:37:54 +00:00
|
|
|
switch (nodetype){
|
|
|
|
case 'frame':
|
|
|
|
case 'lpar,osi':
|
|
|
|
case 'lpar':
|
|
|
|
case 'osi':
|
|
|
|
case 'cec':{
|
|
|
|
parentName = graphicalNodeList[nodeName]['parent'];
|
|
|
|
mtm = graphicalNodeList[nodeName]['mtm'];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'blade':{
|
|
|
|
mpa = graphicalNodeList[nodeName]['mpa'];
|
|
|
|
unit = graphicalNodeList[nodeName]['unit'];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-31 02:28:59 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 04:33:25 +00:00
|
|
|
if ('' == status){
|
|
|
|
status = 'unknown';
|
|
|
|
}
|
|
|
|
|
2011-08-31 02:28:59 +00:00
|
|
|
switch (nodetype){
|
2011-03-23 03:25:01 +00:00
|
|
|
case 'frame': {
|
2010-11-08 07:19:05 +00:00
|
|
|
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;
|
2011-01-17 03:01:46 +00:00
|
|
|
case 'lpar,osi':
|
|
|
|
case 'lpar':
|
|
|
|
case 'osi': {
|
2010-11-08 07:19:05 +00:00
|
|
|
if ('' == parentName){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undefined == fspList[parentName]){
|
2011-08-31 02:28:59 +00:00
|
|
|
fillList(parentName, 'cec');
|
2010-11-08 07:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2011-03-23 03:25:01 +00:00
|
|
|
case 'cec': {
|
2010-11-08 07:19:05 +00:00
|
|
|
if (undefined != fspList[nodeName]){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-10-31 09:37:54 +00:00
|
|
|
fspList[nodeName] = new Object();
|
2010-11-08 07:19:05 +00:00
|
|
|
fspList[nodeName]['children'] = new Array();
|
|
|
|
fspList[nodeName]['mtm'] = mtm;
|
|
|
|
|
|
|
|
if ('' == parentName){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undefined == bpaList[parentName]){
|
2011-08-31 02:28:59 +00:00
|
|
|
fillList(parentName, 'frame');
|
2010-11-08 07:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bpaList[parentName].push(nodeName);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
break;
|
2011-10-31 09:37:54 +00:00
|
|
|
case 'blade': {
|
|
|
|
if (undefined == bladeList[mpa]){
|
|
|
|
bladeList[mpa] = new Array();
|
|
|
|
}
|
|
|
|
bladeList[mpa].push(nodeName + ',' + unit);
|
|
|
|
}
|
2010-11-08 07:19:05 +00:00
|
|
|
default:
|
|
|
|
break;
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2011-10-31 09:37:54 +00:00
|
|
|
function createGraphical(){
|
|
|
|
var tabarea = $('#graphTab');
|
|
|
|
var selectNodeDiv = $('<div id="selectNodeDiv" style="margin: 20px;">Nodes:</div>');
|
|
|
|
var temp = 0;
|
|
|
|
for (var i in selectNode){
|
|
|
|
temp ++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//there is not selected lpars, show the info bar
|
|
|
|
if (0 == temp){
|
|
|
|
tabarea.append(createInfoBar('Hover over a CEC and select the LPARs to do operations against.'));
|
|
|
|
}
|
|
|
|
//show selected lpars
|
|
|
|
else{
|
|
|
|
updateSelectNodeDiv();
|
|
|
|
}
|
|
|
|
|
|
|
|
//add buttons
|
|
|
|
tabarea.append(createActionMenu());
|
|
|
|
tabarea.append(selectNodeDiv);
|
|
|
|
tabarea.append('<table id="graphTable" style="border-color: transparent;"></table>');
|
|
|
|
createSystempGraphical(bpaList, fspList, tabarea);
|
|
|
|
createBladeGraphical(bladeList, tabarea);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
/**
|
2011-10-31 09:37:54 +00:00
|
|
|
* create the physical graphical layout for system p machines
|
2010-11-04 07:07:53 +00:00
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*/
|
2011-10-31 09:37:54 +00:00
|
|
|
function createSystempGraphical(bpa, fsp, area){
|
2010-11-04 07:07:53 +00:00
|
|
|
var usedFsp = new Object();
|
2011-10-31 09:37:54 +00:00
|
|
|
var graphTable = $('#graphTable');
|
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);
|
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
elementNum ++;
|
2011-07-20 21:13:09 +00:00
|
|
|
|
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>');
|
2010-12-09 08:12:26 +00:00
|
|
|
frameDiv.append('<div style="height:27px;" title="' + bpaName + '"><input type="checkbox" class="fspcheckbox" name="check_'+ bpaName +'"></div>');
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2011-01-24 09:55:59 +00:00
|
|
|
//for P7-IH, all the cecs are insert into the frame from down to up, so we had to show the cecs same as the
|
|
|
|
//physical layout.
|
|
|
|
var tempBlankDiv = $('<div></div>');
|
|
|
|
var tempHeight = 0;
|
2010-11-04 07:07:53 +00:00
|
|
|
for (var fspIndex in bpa[bpaName]){
|
|
|
|
var fspName = bpa[bpaName][fspIndex];
|
2011-01-24 09:55:59 +00:00
|
|
|
usedFsp[fspName] = 1;
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-01-24 09:55:59 +00:00
|
|
|
//this is the p7IH, we should add the blank at the top
|
|
|
|
if ((0 == fspIndex) && ('9125-F2C' == fsp[fspName]['mtm'])){
|
|
|
|
frameDiv.append(tempBlankDiv);
|
|
|
|
}
|
2010-11-05 06:38:38 +00:00
|
|
|
frameDiv.append(createFspDiv(fspName, fsp[fspName]['mtm'], fsp));
|
|
|
|
frameDiv.append(createFspTip(fspName, fsp[fspName]['mtm'], fsp));
|
2011-01-24 09:55:59 +00:00
|
|
|
|
|
|
|
tempHeight += coculateBlank(fsp[fspName]['mtm']);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2011-01-24 09:55:59 +00:00
|
|
|
//now the tempHeight are all cecs' height, so we should minus bpa div height and cecs' div height
|
|
|
|
tempHeight = 428 - tempHeight;
|
|
|
|
tempBlankDiv.css('height', tempHeight);
|
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){
|
2011-04-16 14:40:15 +00:00
|
|
|
if (usedFsp[fspName]){
|
2010-11-04 07:07:53 +00:00
|
|
|
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-12-09 08:12:26 +00:00
|
|
|
var td = $('<td style="padding:0;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-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-12-03 09:16:58 +00:00
|
|
|
changeNode(lparName, 'select');
|
2010-11-05 06:38:38 +00:00
|
|
|
}
|
|
|
|
else{
|
2010-12-03 09:16:58 +00:00
|
|
|
changeNode(lparName, 'unselect');
|
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-12-15 10:20:59 +00:00
|
|
|
position: "center right",
|
2010-11-08 07:19:05 +00:00
|
|
|
relative : true,
|
2011-01-18 07:51:07 +00:00
|
|
|
offset : [10, -40],
|
2011-06-16 02:48:34 +00:00
|
|
|
effect: "fade",
|
|
|
|
opacity: 0.9
|
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();
|
2010-12-21 00:52:10 +00:00
|
|
|
$('#nodesDatatable #' + lparName).trigger('click');
|
2010-11-09 07:34:31 +00:00
|
|
|
});
|
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
$('.fspDiv2, .fspDiv4, .fspDiv42').bind('click', function(){
|
|
|
|
var fspName = $(this).attr('value');
|
2010-12-01 07:11:30 +00:00
|
|
|
var selectCount = 0;
|
|
|
|
for (var lparIndex in fspList[fspName]['children']){
|
|
|
|
var lparName = fspList[fspName]['children'][lparIndex];
|
|
|
|
if (selectNode[lparName]){
|
|
|
|
selectCount ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//all the lpars are selected, so unselect nodes
|
|
|
|
if (selectCount == fspList[fspName]['children'].length){
|
|
|
|
for (var lparIndex in fspList[fspName]['children']){
|
|
|
|
var lparName = fspList[fspName]['children'][lparIndex];
|
2010-12-03 09:16:58 +00:00
|
|
|
changeNode(lparName, 'unselect');
|
2010-12-01 07:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//not select all lpars on the cec, so add all lpars into selectNode Hash.
|
|
|
|
else{
|
|
|
|
for (var lparIndex in fspList[fspName]['children']){
|
|
|
|
var lparName = fspList[fspName]['children'][lparIndex];
|
2010-12-03 09:16:58 +00:00
|
|
|
changeNode(lparName, 'select');
|
2010-12-01 07:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateSelectNodeDiv();
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2010-12-09 08:12:26 +00:00
|
|
|
$('.fspcheckbox').bind('click', function(){
|
|
|
|
var itemName = $(this).attr('name');
|
|
|
|
name = itemName.substr(6);
|
|
|
|
|
|
|
|
if ($(this).attr('checked')){
|
|
|
|
selectNode[name] = 1;
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-12-09 08:12:26 +00:00
|
|
|
else{
|
|
|
|
delete selectNode[name];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
2010-12-09 08:12:26 +00:00
|
|
|
|
|
|
|
updateSelectNodeDiv();
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-10-31 09:37:54 +00:00
|
|
|
function createBladeGraphical(blades, area){
|
|
|
|
var graphTable = $('#graphTable');
|
|
|
|
var mpa = '';
|
|
|
|
var bladename = '';
|
|
|
|
var index = 0;
|
|
|
|
var mpaNumber = 0;
|
|
|
|
var row;
|
|
|
|
|
|
|
|
for (mpa in blades){
|
|
|
|
var tempArray = new Array(14);
|
|
|
|
var bladeInfo = new Array();
|
|
|
|
var unit = 0;
|
|
|
|
if (0 == mpaNumber % 3){
|
|
|
|
row = $('<tr></tr>');
|
|
|
|
graphTable.append(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
mpaNumber ++;
|
|
|
|
|
|
|
|
var td = $('<td style="padding:0;border-color: transparent;"></td>');
|
|
|
|
var chasisDiv = $('<div class="chasisDiv" title=' + mpa + '></div></div>');
|
|
|
|
|
|
|
|
|
|
|
|
//fill the array with blade information, to create the empty slot
|
|
|
|
for (var index in blades[mpa]){
|
|
|
|
bladeInfo = blades[mpa][index].split(',');
|
|
|
|
unit = parseInt(bladeInfo[1]);
|
|
|
|
tempArray[unit - 1] = bladeInfo[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//draw the blades and empty slot in chasis
|
|
|
|
for (var index = 0; index < 14; index++){
|
|
|
|
if (tempArray[index]){
|
|
|
|
bladename = tempArray[index];
|
|
|
|
chasisDiv.append('<div id="' + bladename + '" class="bladeDiv bladeInsertDiv" title="' + bladename + '"></div>');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
chasisDiv.append('<div class="bladeDiv"></div>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
td.append(chasisDiv);
|
|
|
|
row.append(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
/**
|
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-12-17 05:13:13 +00:00
|
|
|
$('#selectNodeDiv').append('Nodes: ');
|
2010-11-12 07:46:42 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the action menu
|
|
|
|
*
|
|
|
|
* @param getNodesFunction
|
|
|
|
* the function that can find selected nodes name
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return action menu object
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
|
|
|
function createActionMenu(){
|
2011-09-09 14:53:17 +00:00
|
|
|
// Create action bar
|
2010-11-04 07:07:53 +00:00
|
|
|
var actionBar = $('<div class="actionBar"></div>');
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Power on
|
2010-11-04 07:07:53 +00:00
|
|
|
var powerOnLnk = $('<a>Power on</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
powerOnLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2010-11-04 07:07:53 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'rpower',
|
|
|
|
tgt : tgtNodes,
|
|
|
|
args : 'on',
|
|
|
|
msg : ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2011-09-09 14:53:17 +00:00
|
|
|
|
|
|
|
// Power off
|
2010-11-04 07:07:53 +00:00
|
|
|
var powerOffLnk = $('<a>Power off</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
powerOffLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
2011-04-16 14:40:15 +00:00
|
|
|
$.ajax({
|
2010-11-04 07:07:53 +00:00
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'rpower',
|
|
|
|
tgt : tgtNodes,
|
|
|
|
args : 'off',
|
|
|
|
msg : ''
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2011-09-09 14:53:17 +00:00
|
|
|
|
|
|
|
// Delete
|
2010-11-04 07:07:53 +00:00
|
|
|
var deleteLnk = $('<a>Delete</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
deleteLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
2010-11-24 18:11:42 +00:00
|
|
|
loadDeletePage(tgtNodes);
|
2010-11-12 07:46:42 +00:00
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Unlock
|
2010-11-04 07:07:53 +00:00
|
|
|
var unlockLnk = $('<a>Unlock</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
unlockLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadUnlockPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Run script
|
2010-11-04 07:07:53 +00:00
|
|
|
var scriptLnk = $('<a>Run script</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
scriptLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadScriptPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Update
|
2010-11-04 07:07:53 +00:00
|
|
|
var updateLnk = $('<a>Update</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
updateLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadUpdatenodePage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Set boot state
|
2010-11-04 07:07:53 +00:00
|
|
|
var setBootStateLnk = $('<a>Set boot state</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
setBootStateLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadNodesetPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Boot to network
|
2010-11-04 07:07:53 +00:00
|
|
|
var boot2NetworkLnk = $('<a>Boot to network</a>');
|
2011-09-09 14:53:17 +00:00
|
|
|
boot2NetworkLnk.click(function() {
|
2010-11-12 07:46:42 +00:00
|
|
|
var tgtNodes = getSelectNodes();
|
|
|
|
if (tgtNodes) {
|
|
|
|
loadNetbootPage(tgtNodes);
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
});
|
2011-09-09 14:53:17 +00:00
|
|
|
|
|
|
|
// Remote console
|
|
|
|
var rconLnk = $('<a>Open console</a>');
|
|
|
|
rconLnk.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);
|
|
|
|
}
|
|
|
|
});
|
2010-12-10 15:43:35 +00:00
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Edit properties
|
2010-12-10 15:43:35 +00:00
|
|
|
var editProps = $('<a>Edit properties</a>');
|
|
|
|
editProps.bind('click', function(event){
|
|
|
|
for (var node in selectNode) {
|
|
|
|
loadEditPropsPage(node);
|
|
|
|
}
|
|
|
|
});
|
2011-09-09 14:53:17 +00:00
|
|
|
|
|
|
|
// Actions
|
|
|
|
var actionsLnk = '<a>Actions</a>';
|
|
|
|
var actsMenu = createMenu([deleteLnk, powerOnLnk, powerOffLnk, scriptLnk]);
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Configurations
|
|
|
|
var configLnk = '<a>Configuration</a>';
|
|
|
|
var configMenu = createMenu([unlockLnk, updateLnk, editProps]);
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Provision
|
|
|
|
var provLnk = '<a>Provision</a>';
|
|
|
|
var provMenu = createMenu([boot2NetworkLnk, setBootStateLnk, rconLnk]);
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-09-09 14:53:17 +00:00
|
|
|
// Create an action menu
|
|
|
|
var actionsMenu = createMenu([ [ actionsLnk, actsMenu ], [ configLnk, configMenu ], [ provLnk, provMenu ] ]);
|
|
|
|
actionsMenu.superfish();
|
|
|
|
actionsMenu.css('display', 'inline-block');
|
|
|
|
actionBar.append(actionsMenu);
|
|
|
|
actionBar.css('margin-top', '10px');
|
2010-11-04 07:07:53 +00:00
|
|
|
|
2011-09-28 20:01:24 +00:00
|
|
|
// Set correct theme for action menu
|
|
|
|
actionsMenu.find('li').hover(function() {
|
2011-09-28 21:38:12 +00:00
|
|
|
setMenu2Theme($(this));
|
2011-09-28 20:01:24 +00:00
|
|
|
}, function() {
|
2011-09-28 21:38:12 +00:00
|
|
|
setMenu2Normal($(this));
|
2011-09-28 20:01:24 +00:00
|
|
|
});
|
|
|
|
|
2010-11-04 07:07:53 +00:00
|
|
|
return actionBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create the physical graphical layout
|
|
|
|
*
|
|
|
|
* @param bpaName : fsp's key
|
|
|
|
* fsp : all fsp and there related lpars
|
|
|
|
* fspinfo : all fsps' hardwareinfo
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
|
|
|
function createFspDiv(fspName, mtm, fsp){
|
|
|
|
//create fsp title
|
|
|
|
var lparStatusRow = '';
|
2011-01-17 03:01:46 +00:00
|
|
|
var temp = '';
|
2010-11-04 07:07:53 +00:00
|
|
|
|
|
|
|
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]);
|
2011-01-14 20:25:14 +00:00
|
|
|
lparStatusRow += '<td class="lparStatus" style="background-image:url(images/nodes/' + color + '.gif);padding: 0px;" name="' + lparName + '"></td>';
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//select the backgroud
|
|
|
|
var divClass = '';
|
2011-01-17 03:01:46 +00:00
|
|
|
if ('' == mtm){
|
|
|
|
temp = '8231-E2B';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
temp = mtm;
|
|
|
|
}
|
|
|
|
if (hardwareInfo[temp][1]){
|
|
|
|
divClass += 'fspDiv' + hardwareInfo[temp][1];
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
divClass += 'fspDiv4';
|
|
|
|
}
|
|
|
|
|
|
|
|
//create return value
|
2011-01-24 09:55:59 +00:00
|
|
|
var retHtml = '<input style="padding:0;" class="fspcheckbox" type="checkbox" name="check_' + fspName + '">';
|
2010-12-09 08:12:26 +00:00
|
|
|
retHtml += '<div value="' + fspName + '" class="' + divClass + '">';
|
2010-11-05 06:38:38 +00:00
|
|
|
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
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return
|
2010-11-05 06:38:38 +00:00
|
|
|
*/
|
|
|
|
function createFspTip(fspName, mtm, fsp){
|
|
|
|
var tip = $('<div class="tooltip"></div>');
|
|
|
|
var tempTable = $('<table><tbody></tbody></table>');
|
2011-01-17 03:01:46 +00:00
|
|
|
var temp = '';
|
|
|
|
if ('' == mtm){
|
|
|
|
temp = 'unkown';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
temp = mtm;
|
|
|
|
}
|
2011-07-20 21:13:09 +00:00
|
|
|
|
2011-01-17 03:01:46 +00:00
|
|
|
if (hardwareInfo[temp]){
|
|
|
|
tip.append('<h3>' + fspName + '(' + hardwareInfo[temp][0] + ')</h3><br/>');
|
2010-11-05 06:38:38 +00:00
|
|
|
}
|
|
|
|
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
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return corresponding color name
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
|
|
|
function statusMap(status){
|
|
|
|
var color = 'gainsboro';
|
|
|
|
|
|
|
|
switch(status){
|
|
|
|
case 'alive':
|
|
|
|
case 'ready':
|
|
|
|
case 'pbs':
|
|
|
|
case 'sshd':
|
2011-04-11 02:23:32 +00:00
|
|
|
case 'booting':
|
|
|
|
case 'ping':{
|
2010-11-04 07:07:53 +00:00
|
|
|
color = 'green';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'noping':
|
|
|
|
case 'unreachable':{
|
|
|
|
color = 'red';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2010-12-15 10:20:59 +00:00
|
|
|
color = 'grey';
|
2010-11-04 07:07:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select all lpars checkbox in the dialog
|
|
|
|
*
|
|
|
|
* @param
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
|
|
|
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
|
2011-04-16 14:40:15 +00:00
|
|
|
* @return lpars' string
|
2010-11-04 07:07:53 +00:00
|
|
|
*/
|
2011-04-11 02:23:32 +00:00
|
|
|
function getSelectNodes() {
|
|
|
|
var ret = '';
|
|
|
|
for ( var lparName in selectNode) {
|
|
|
|
ret += lparName + ',';
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.substring(0, ret.length - 1);
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 09:16:58 +00:00
|
|
|
/**
|
|
|
|
* when the node is selected or unselected, then update the area on cec, update the global
|
|
|
|
* list and update the tooltip table
|
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
function changeNode(lparName, status){
|
2010-12-15 10:20:59 +00:00
|
|
|
var imgUrl = '';
|
|
|
|
var checkFlag = true;
|
2010-12-03 09:16:58 +00:00
|
|
|
if ('select' == status){
|
|
|
|
selectNode[lparName] = 1;
|
2011-01-14 20:25:14 +00:00
|
|
|
imgUrl = 'url(images/nodes/s-'+ statusMap(lparList[lparName]) + '.gif)';
|
2010-12-15 10:20:59 +00:00
|
|
|
checkFlag = true;
|
2010-12-03 09:16:58 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
delete selectNode[lparName];
|
2011-01-14 20:25:14 +00:00
|
|
|
imgUrl = 'url(images/nodes/'+ statusMap(lparList[lparName]) + '.gif)';
|
2010-12-15 10:20:59 +00:00
|
|
|
checkFlag = false;
|
2010-12-03 09:16:58 +00:00
|
|
|
}
|
2010-12-15 10:20:59 +00:00
|
|
|
$('#graphTable [name=' + lparName + ']').css('background-image', imgUrl);
|
|
|
|
$('.tooltip input[name="' + lparName + '"]').attr('checked', checkFlag);
|
2011-01-24 09:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The P7-IH's cecs are insert from down to up, so we had to coculate the blank height.
|
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* @return the height for the cec
|
|
|
|
*/
|
|
|
|
function coculateBlank(mtm){
|
|
|
|
if ('' == mtm){
|
|
|
|
return 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hardwareInfo[mtm]){
|
|
|
|
return 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(hardwareInfo[mtm]){
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
return 13;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
return 24;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
return 47;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
2010-11-04 07:07:53 +00:00
|
|
|
}
|