get all graphical information by one request
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10653 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
282feb6f6e
commit
2d9ef64cb5
@ -190,43 +190,6 @@ function drawPieSummary(index, valuePair){
|
||||
location: 'e'
|
||||
}
|
||||
});
|
||||
|
||||
// container.bind('jqplotDataClick',loadSummaryDetail);
|
||||
// container.bind('jqplotDataHighlight',function(){this.style.cursor='pointer';});
|
||||
// container.bind('jqplotDataUnhighlight',function(){this.style.cursor='';});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load node summary details
|
||||
*
|
||||
* @param ev
|
||||
* @param seriesIndex
|
||||
* @param pointIndex
|
||||
* @param data
|
||||
* @return Nothing
|
||||
*/
|
||||
function loadSummaryDetail(ev, seriesIndex, pointIndex, data){
|
||||
var temp = $(this).attr('id');
|
||||
temp = temp.replace('pie', '');
|
||||
var table = '';
|
||||
switch (temp) {
|
||||
case 'os':
|
||||
case 'arch':
|
||||
case 'provmethod':
|
||||
case 'nodetype':
|
||||
table = 'nodetype';
|
||||
break;
|
||||
case 'status':
|
||||
table = 'nodelist';
|
||||
break;
|
||||
}
|
||||
|
||||
var args = table + '.' + temp + '==';
|
||||
if (data[0] != 'unknown') {
|
||||
args += data[0];
|
||||
}
|
||||
|
||||
drawNodesArea('', args, '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,8 +3,6 @@ var fspList;
|
||||
var lparList;
|
||||
var graphicalNodeList;
|
||||
var selectNode;
|
||||
var graphicalDataType = ['ppc.nodetype', 'nodetype.nodetype', 'ppc.parent', 'nodelist.status', 'vpd.mtm'];
|
||||
var gettingDataFlag = false;
|
||||
|
||||
/**
|
||||
* get all nodes useful attributes from remote server.
|
||||
@ -14,61 +12,23 @@ var gettingDataFlag = false;
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function initGraphicalData(dataTypeIndex, attrNullNode){
|
||||
gettingDataFlag = true;
|
||||
var tempTgt = 'all';
|
||||
if (undefined == dataTypeIndex){
|
||||
dataTypeIndex = 0;
|
||||
}
|
||||
|
||||
if ((dataTypeIndex < 0) || (dataTypeIndex > 4)){
|
||||
return;
|
||||
}
|
||||
|
||||
//there two nodetype field in database in table ppc and nodetype. we should query ppc.nodetype first,
|
||||
//if the ppc.nodetype is NULL, then query the nodetype.nodetype.
|
||||
if (1 == dataTypeIndex){
|
||||
if (!attrNullNode){
|
||||
initGraphicalData(2);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
tempTgt = attrNullNode;
|
||||
}
|
||||
}
|
||||
|
||||
var typeName = graphicalDataType[dataTypeIndex];
|
||||
$('#graphTab img').remove();
|
||||
$('#graphTab').append('<br/>Getting ' + typeName).append(createLoader());
|
||||
function initGraphicalData(){
|
||||
$('#graphTab').append(createLoader());
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'nodels',
|
||||
tgt : tempTgt,
|
||||
args : typeName,
|
||||
msg : 'index' + dataTypeIndex.toString()
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'graph',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data){
|
||||
var tempIndex = Number(data.msg.substr(5, 1));
|
||||
var tempNodeList = extractGraphicalData(data);
|
||||
if (tempIndex < graphicalDataType.length - 1){
|
||||
tempIndex ++;
|
||||
initGraphicalData(tempIndex, tempNodeList);
|
||||
}
|
||||
else{
|
||||
gettingDataFlag = false;
|
||||
$('#graphTab').empty();
|
||||
for (var temp in nodesList){
|
||||
var nodeName = nodesList[temp];
|
||||
if ('' == nodeName){
|
||||
continue;
|
||||
}
|
||||
fillList(nodeName);
|
||||
}
|
||||
createGraphical(bpaList, fspList, $('#graphTab'));
|
||||
success: function(data){
|
||||
if(!data.rsp[0]){
|
||||
return;
|
||||
}
|
||||
extractGraphicalData(data.rsp[0]);
|
||||
getNodesAndDraw();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -80,65 +40,49 @@ function initGraphicalData(dataTypeIndex, attrNullNode){
|
||||
* @return nodes list for next time query
|
||||
*/
|
||||
function extractGraphicalData(data){
|
||||
var nodes = data.rsp;
|
||||
var tempNullNodes ='';
|
||||
var nodes = data.split(';');
|
||||
var attrs;
|
||||
var nodename;
|
||||
//extract useful info into tempList
|
||||
for (var i = 0; i < nodes.length; i++){
|
||||
var nodeName = nodes[i][0];
|
||||
if (undefined == graphicalNodeList[nodeName]){
|
||||
graphicalNodeList[nodeName] = new Object();
|
||||
attrs = nodes[i].split(':');
|
||||
nodename = attrs[0];
|
||||
if (undefined == graphicalNodeList[nodename]){
|
||||
graphicalNodeList[nodename] = new Object();
|
||||
}
|
||||
|
||||
if('' == nodeName){
|
||||
tempNullNodes = 'all,';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (data.msg.substr(5, 1)){
|
||||
case '0':
|
||||
case '1':{
|
||||
if (!nodes[i][1]){
|
||||
tempNullNodes += nodeName + ',';
|
||||
break;
|
||||
}
|
||||
graphicalNodeList[nodeName]['type'] = nodes[i][1];
|
||||
}
|
||||
break;
|
||||
case '2' : {
|
||||
graphicalNodeList[nodeName]['parent'] = nodes[i][1];
|
||||
}
|
||||
break;
|
||||
case '3': {
|
||||
graphicalNodeList[nodeName]['status'] = nodes[i][1];
|
||||
}
|
||||
break;
|
||||
case '4': {
|
||||
graphicalNodeList[nodeName]['mtm'] = nodes[i][1];
|
||||
}
|
||||
break;
|
||||
default :
|
||||
switch(attrs[1].toLowerCase()){
|
||||
case 'cec':
|
||||
case 'frame':
|
||||
case 'lpar':
|
||||
case 'lpar,osi':
|
||||
case 'osi,lpar':
|
||||
graphicalNodeList[nodename]['type'] = attrs[1];
|
||||
graphicalNodeList[nodename]['parent'] = attrs[2];
|
||||
graphicalNodeList[nodename]['mtm'] = attrs[3];
|
||||
graphicalNodeList[nodename]['status'] = attrs[4];
|
||||
break;
|
||||
case 'blade':
|
||||
graphicalNodeList[nodename]['type'] = attrs[1];
|
||||
graphicalNodeList[nodename]['mpa'] = attrs[2];
|
||||
graphicalNodeList[nodename]['unit'] = attrs[3];
|
||||
graphicalNodeList[nodename]['status'] = attrs[4];
|
||||
break;
|
||||
case 'systemx':
|
||||
graphicalNodeList[nodename]['type'] = attrs[1];
|
||||
graphicalNodeList[nodename]['rack'] = attrs[2];
|
||||
graphicalNodeList[nodename]['unit'] = attrs[3];
|
||||
graphicalNodeList[nodename]['mtm'] = attrs[4];
|
||||
graphicalNodeList[nodename]['status'] = attrs[5];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ('' != tempNullNodes){
|
||||
tempNullNodes = tempNullNodes.substr(0, tempNullNodes.length - 1);
|
||||
}
|
||||
return tempNullNodes;
|
||||
}
|
||||
|
||||
function createPhysicalLayout(nodeList){
|
||||
var flag = false;
|
||||
|
||||
//no nodes are selected.
|
||||
if (!nodeList){
|
||||
return;
|
||||
}
|
||||
|
||||
//it is getting data,so we had to wait now.
|
||||
if (gettingDataFlag){
|
||||
return;
|
||||
}
|
||||
|
||||
//when the graphical layout is shown, do not need to redraw
|
||||
if (1 < $('#graphTab').children().length){
|
||||
return;
|
||||
@ -160,21 +104,38 @@ function createPhysicalLayout(nodeList){
|
||||
//there is not graphical data, get the info now
|
||||
if (!flag){
|
||||
graphicalNodeList = new Object();
|
||||
initGraphicalData(0);
|
||||
initGraphicalData();
|
||||
}
|
||||
else{
|
||||
$('#graphTab').empty();
|
||||
for (var temp in nodeList){
|
||||
var nodeName = nodeList[temp];
|
||||
if ('' == nodeName){
|
||||
continue;
|
||||
}
|
||||
fillList(nodeName);
|
||||
}
|
||||
createGraphical(bpaList, fspList, $('#graphTab'));
|
||||
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);
|
||||
}
|
||||
$('#graphTab').empty();
|
||||
createGraphical(bpaList, fspList, $('#graphTab'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fillList(nodeName, defaultnodetype){
|
||||
var parentName = '';
|
||||
var mtm = '';
|
||||
|
@ -56,7 +56,8 @@ sub process_request {
|
||||
'gangliashow' => \&web_gangliaShow,
|
||||
'gangliacurrent' => \&web_gangliaLatest,
|
||||
'rinstall' => \&web_rinstall,
|
||||
'addnode' => \&web_addnode
|
||||
'addnode' => \&web_addnode,
|
||||
'graph' => \&web_graphinfo
|
||||
);
|
||||
|
||||
#check whether the request is authorized or not
|
||||
@ -1948,4 +1949,179 @@ sub web_addnode{
|
||||
`cat /tmp/webrscan.tmp | chdef -z`;
|
||||
unlink('/tmp/webrscan.tmp');
|
||||
}
|
||||
|
||||
sub web_graphinfo{
|
||||
my ( $request, $callback, $sub_req ) = @_;
|
||||
my $nodetypeTab;
|
||||
my @nodes;
|
||||
my @parray;
|
||||
my @bladearray;
|
||||
my @xarray;
|
||||
my %phash;
|
||||
my %bladehash;
|
||||
my %xhash;
|
||||
my @unsupportarray;
|
||||
my @missinfoarray;
|
||||
my $result;
|
||||
my $pretstr = '';
|
||||
my $bladeretstr = '';
|
||||
my $xretstr = '';
|
||||
my $unsupretstr = '';
|
||||
my $missretstr = '';
|
||||
|
||||
@nodes = xCAT::DBobjUtils->getObjectsOfType('node');
|
||||
|
||||
$nodetypeTab = xCAT::Table->new('nodetype');
|
||||
unless($nodetypeTab){
|
||||
return;
|
||||
}
|
||||
|
||||
#get all nodes type to seperate nodes into different group
|
||||
$result = $nodetypeTab->getNodesAttribs(\@nodes,['nodetype']);
|
||||
while(my ($key, $value) = each(%$result)){
|
||||
my $temptype = $value->[0]->{'nodetype'};
|
||||
if ($temptype =~ /(ppc|lpar|cec|frame)/i){
|
||||
push(@parray, $key);
|
||||
}
|
||||
elsif ($temptype =~ /blade/i){
|
||||
push(@bladearray, $key);
|
||||
}
|
||||
elsif ($temptype =~ /osi/i){
|
||||
push(@xarray, $key);
|
||||
}
|
||||
else{
|
||||
push(@unsupportarray, $key);
|
||||
}
|
||||
}
|
||||
$nodetypeTab->close();
|
||||
|
||||
#get all infomations for system p node
|
||||
if (scalar(@parray) > 0){
|
||||
my $ppctab = xCAT::Table->new('ppc');
|
||||
#nodetype, parent
|
||||
$result = $ppctab->getNodesAttribs(\@parray, ['parent']);
|
||||
foreach(@parray){
|
||||
my $value = $result->{$_};
|
||||
if ($value->[0]){
|
||||
$phash{$_} = xCAT::DBobjUtils->getnodetype($_) . ':' . $value->[0]->{'parent'} . ':';
|
||||
}
|
||||
else{
|
||||
push(@missinfoarray, $_);
|
||||
}
|
||||
}
|
||||
$ppctab->close();
|
||||
|
||||
undef @parray;
|
||||
@parray = keys %phash;
|
||||
}
|
||||
if (scalar(@parray) > 0){
|
||||
#mtm
|
||||
my $vpdtab = xCAT::Table->new('vpd');
|
||||
$result = $vpdtab->getNodesAttribs(\@parray, ['mtm']);
|
||||
foreach(@parray){
|
||||
my $value = $result->{$_};
|
||||
$phash{$_} = $phash{$_} . $value->[0]->{'mtm'} . ':';
|
||||
}
|
||||
$vpdtab->close();
|
||||
|
||||
#status
|
||||
my $nodelisttab = xCAT::Table->new('nodelist');
|
||||
$result = $nodelisttab->getNodesAttribs(\@parray, ['status']);
|
||||
foreach(@parray){
|
||||
my $value = $result->{$_};
|
||||
$phash{$_} = $phash{$_} . $value->[0]->{'status'};
|
||||
}
|
||||
$nodelisttab->close();
|
||||
|
||||
while(my ($key, $value) = each(%phash)){
|
||||
$pretstr = $pretstr . $key . ':' . $value . ';';
|
||||
}
|
||||
}
|
||||
|
||||
#get all information for blade node
|
||||
if (scalar(@bladearray) > 0){
|
||||
#mpa, id
|
||||
my $mptab = xCAT::Table->new('mp');
|
||||
$result = $mptab->getNodesAttribs(\@bladearray, ['mpa', 'id']);
|
||||
foreach(@bladearray){
|
||||
my $value = $result->{$_};
|
||||
if ($value->[0]->{'mpa'}){
|
||||
$bladehash{$_} = 'blade:' . $value->[0]->{'mpa'} . ':' . $value->[0]->{'id'} . ':';
|
||||
}
|
||||
else{
|
||||
push(@missinfoarray, $_);
|
||||
}
|
||||
}
|
||||
$mptab->close();
|
||||
|
||||
undef @bladearray;
|
||||
@bladearray = keys %bladehash;
|
||||
}
|
||||
if (scalar(@bladearray) > 0){
|
||||
#status
|
||||
my $nodelisttab = xCAT::Table->new('nodelist');
|
||||
$result = $nodelisttab->getNodesAttribs(\@bladearray, ['status']);
|
||||
foreach(@bladearray){
|
||||
my $value = $result->{$_};
|
||||
$bladehash{$_} = $bladehash{$_} . $value->[0]->{'status'};
|
||||
}
|
||||
$nodelisttab->close();
|
||||
while(my ($key, $value) = each(%bladehash)){
|
||||
$bladeretstr = $bladeretstr . $key . ':' . $value . ';';
|
||||
}
|
||||
}
|
||||
|
||||
#get all information for system x node
|
||||
if (scalar(@xarray) > 0){
|
||||
#rack, unit
|
||||
my $nodepostab = xCAT::Table->new('nodepos');
|
||||
$result = $nodepostab->getNodesAttribs(\@xarray, ['rack', 'u']);
|
||||
foreach(@xarray){
|
||||
my $value = $result->{$_};
|
||||
if ($value->[0]->{'rack'}){
|
||||
$xhash{$_} = 'systemx:' . $value->[0]->{'rack'} . ':' . $value->[0]->{'u'} . ':';
|
||||
}
|
||||
else{
|
||||
push(@missinfoarray, $_);
|
||||
}
|
||||
}
|
||||
$nodepostab->close();
|
||||
|
||||
undef @xarray;
|
||||
@xarray = keys %xhash;
|
||||
}
|
||||
if (scalar(@xarray) > 0){
|
||||
#mtm
|
||||
my $vpdtab = xCAT::Table->new('vpd');
|
||||
$result = $vpdtab->getNodesAttribs(\@xarray, ['mtm']);
|
||||
foreach(@xarray){
|
||||
my $value = $result->{$_};
|
||||
$xhash{$_} = $xhash{$_} . $value->[0]->{'mtm'} . ':';
|
||||
}
|
||||
$vpdtab->close();
|
||||
|
||||
#status
|
||||
my $nodelisttab = xCAT::Table->new('nodelist');
|
||||
$result = $nodelisttab->getNodesAttribs(\@xarray, ['status']);
|
||||
foreach(@xarray){
|
||||
my $value = $result->{$_};
|
||||
$xhash{$_} = $xhash{$_} . $value->[0]->{'status'};
|
||||
}
|
||||
while(my ($key, $value) = each(%xhash)){
|
||||
$xretstr = $xretstr . $key . ':' . $value . ';';
|
||||
}
|
||||
}
|
||||
|
||||
foreach(@missinfoarray){
|
||||
$missretstr = $missretstr . $_ . ':miss;';
|
||||
}
|
||||
|
||||
#combine all information into a string
|
||||
my $retstr = $pretstr . $bladeretstr . $xretstr . $missretstr;
|
||||
if ($retstr){
|
||||
$retstr = substr($retstr, 0, -1);
|
||||
}
|
||||
|
||||
$callback->({data => $retstr});
|
||||
}
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user