change conditions node list and monitor scope
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8506 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
d491487ce9
commit
e2a92a3c97
@ -707,11 +707,22 @@ function showEventLog(data){
|
||||
*
|
||||
*/
|
||||
function loadRmcEventConfig(){
|
||||
var chCondScopeBut = createButton('Change Condition Scope');
|
||||
chCondScopeBut.bind('click', function(){
|
||||
chCondScopeDia();
|
||||
});
|
||||
$('#rmcEventDiv').append(chCondScopeBut);
|
||||
|
||||
var mkResponseBut = createButton('Make Response');
|
||||
mkResponseBut.bind('click', function(){
|
||||
mkResponseDia();
|
||||
});
|
||||
$('#rmcEventDiv').append(mkResponseBut);
|
||||
|
||||
var mkConResBut = createButton('Make Association');
|
||||
mkConResBut.bind('click', function(){
|
||||
mkCondRespDia();
|
||||
});
|
||||
|
||||
$('#rmcEventDiv').append(mkConResBut);
|
||||
}
|
||||
|
||||
@ -754,4 +765,148 @@ function mkCondRespDia(){
|
||||
*/
|
||||
function rmCondRespDia(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* show the make condition dialogue
|
||||
*
|
||||
* @param
|
||||
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
function chCondScopeDia(){
|
||||
var diaDiv = $('<div title="Change Condition Scope" id="chScopeDiaDiv"><div>');
|
||||
diaDiv.append('<fieldset id="changePreCond"><legend>Predefined Condition</legend></fieldset>');
|
||||
diaDiv.append('<fieldset id="changeGroup"><legend>Group</legend></fieldset>');
|
||||
diaDiv.append('<fieldset id="changeStatus"></fieldset>');
|
||||
|
||||
diaDiv.dialog({
|
||||
modal: true,
|
||||
width: 570,
|
||||
close: function(event, ui){
|
||||
$(this).remove();
|
||||
},
|
||||
buttons: {
|
||||
cancel : function(){
|
||||
$(this).dialog('close');
|
||||
},
|
||||
ok : function(){
|
||||
$('#changeStatus').empty().append('<legend>Status</legend>');
|
||||
var conditionName = $('#changePreCond :checked').attr('value');
|
||||
var groupName = '';
|
||||
$('#changeGroup :checked').each(function(){
|
||||
if ('' == groupName){
|
||||
groupName += $(this).attr('value');
|
||||
}
|
||||
else{
|
||||
groupName += ',' + $(this).attr('value');
|
||||
}
|
||||
});
|
||||
|
||||
if (undefined == conditionName){
|
||||
$('#changeStatus').append('Please select conditon.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ('' == groupName){
|
||||
$('#changeStatus').append('Please select group.');
|
||||
return;
|
||||
}
|
||||
|
||||
$('#changeStatus').append(createLoader());
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'mkcondition;change;' + conditionName + ';' + groupName,
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data){
|
||||
$('#changeStatus img').remove();
|
||||
if (-1 != data.rsp[0].indexOf('Error')){
|
||||
$('#changeStatus').append(data.rsp[0]);
|
||||
}
|
||||
else{
|
||||
$('#rmcEventStatus').empty().append(data.rsp[0]);
|
||||
$('#chScopeDiaDiv').remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#changePreCond').append('Getting predefined conditions.');
|
||||
$('#changePreCond').append(createLoader());
|
||||
var groups = $.cookie('groups').split(',');
|
||||
for (var i in groups){
|
||||
var tempStr = '<input type="checkbox" value="' + groups[i] + '">' + groups[i];
|
||||
$('#changeGroup').append(tempStr);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'lscondition',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data){
|
||||
$('#changePreCond').empty();
|
||||
var conditions = data.rsp[0].split(';');
|
||||
var name = '';
|
||||
var showStr = '<legend>Predefined Condition</legend><table style="font:12px verdana,arial,helvetica,sans-serif;"><tbody>';
|
||||
for (var i in conditions){
|
||||
name = conditions[i];
|
||||
name = name.substr(1, name.length - 2);
|
||||
if (0 == i % 2){
|
||||
showStr += '<tr><td><input type="radio" name="preCond" value="'+ name + '">' + name + '</td><td width=10></td>' ;
|
||||
}
|
||||
else{
|
||||
showStr += '<td><input type="radio" name="preCond" value="'+ name + '">' + name + '</td></tr>';
|
||||
}
|
||||
}
|
||||
showStr += '</tbody></table>';
|
||||
|
||||
$('#changePreCond').append(showStr);
|
||||
//adjust the dialog's position
|
||||
$('#chScopeDiaDiv').dialog( "option", "position", 'center' );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* show the make response dialogue
|
||||
*
|
||||
* @param
|
||||
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
function mkResponseDia(){
|
||||
var diaDiv = $('<div title="Make Response"><div>');
|
||||
diaDiv.append('under construction.');
|
||||
|
||||
diaDiv.dialog({
|
||||
modal: true,
|
||||
width: 400,
|
||||
close: function(event, ui){
|
||||
$(this).remove();
|
||||
},
|
||||
buttons: {
|
||||
cancel : function(){
|
||||
$(this).dialog('close');
|
||||
},
|
||||
ok : function(){
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@ -53,7 +53,7 @@ sub process_request {
|
||||
'gangliastop' => \&web_gangliastop,
|
||||
'gangliastatus' => \&web_gangliastatus,
|
||||
'gangliacheck' => \&web_gangliacheck,
|
||||
|
||||
'mkcondition' => \&web_mkcondition,
|
||||
#'xdsh' => \&web_xdsh,
|
||||
#THIS list needs to be updated
|
||||
);
|
||||
@ -187,29 +187,98 @@ sub web_stopcondresp {
|
||||
|
||||
sub web_lscond {
|
||||
my ( $request, $callback, $sub_req ) = @_;
|
||||
my $ret = `lscondition`;
|
||||
my $nodeRange = $request->{arg}->[1];
|
||||
my $names = '';
|
||||
|
||||
my @lines = split '\n', $ret;
|
||||
shift @lines;
|
||||
shift @lines;
|
||||
foreach my $line (@lines) {
|
||||
$callback->( { data => $line } );
|
||||
#list all the conditions on all lpars in this group
|
||||
if ($nodeRange){
|
||||
my @nodes = xCAT::NodeRange::noderange($nodeRange);
|
||||
my %tempHash;
|
||||
my $nodeCount = @nodes;
|
||||
#no node in this group
|
||||
if (1 > $nodeCount){
|
||||
return;
|
||||
}
|
||||
|
||||
#no conditions return
|
||||
my $tempCmd = 'lscondition -d :' . join(',', @nodes);
|
||||
my $retInfo = xCAT::Utils->runcmd($tempCmd, -1, 1);
|
||||
if (1 > @$retInfo){
|
||||
return;
|
||||
}
|
||||
|
||||
shift @$retInfo;
|
||||
shift @$retInfo;
|
||||
|
||||
foreach my $line (@$retInfo){
|
||||
my @temp = split(':', $line);
|
||||
$tempHash{@temp[0]}++;
|
||||
}
|
||||
|
||||
foreach my $name (keys (%tempHash)){
|
||||
if ($nodeCount == $tempHash{$name}){
|
||||
$names = $names . $name . ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
#only list the conditions on local.
|
||||
else{
|
||||
my $retInfo = xCAT::Utils->runcmd('lscondition -d', -1, 1);
|
||||
|
||||
shift @$retInfo;
|
||||
shift @$retInfo;
|
||||
foreach my $line (@$retInfo) {
|
||||
my @temp = split(':', $line);
|
||||
$names = $names . @temp[0] . ';';
|
||||
}
|
||||
}
|
||||
if ('' eq $names){
|
||||
return;
|
||||
}
|
||||
$names = substr($names, 0, (length($names) - 1));
|
||||
|
||||
$callback->( { data => $names } );
|
||||
}
|
||||
|
||||
sub web_mkcondition{
|
||||
my ( $request, $callback, $sub_req ) = @_;
|
||||
|
||||
if ('change' eq $request->{arg}->[1]){
|
||||
my @nodes;
|
||||
my $conditionName = $request->{arg}->[2];
|
||||
my $groupName = $request->{arg}->[3];
|
||||
|
||||
my $retInfo = xCAT::Utils->runcmd('nodels ' . $groupName . " nodetype.nodetype", -1, 1);
|
||||
foreach my $line (@$retInfo){
|
||||
my @temp = split(':', $line);
|
||||
if (@temp[1] !~ /lpar/){
|
||||
$callback->( { data => 'Error : only the compute nodes\' group could select.' } );
|
||||
return;
|
||||
}
|
||||
push (@nodes, @temp[0]);
|
||||
}
|
||||
|
||||
#xCAT::Utils->runcmd('chcondition -n ' + join(',', @nodes) + '-m m ' + $conditionName);
|
||||
$callback->( { data => 'Change scope success.' } );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub web_lsresp {
|
||||
my ( $request, $callback, $sub_req ) = @_;
|
||||
my $ret = `lsresponse`;
|
||||
my @resps;
|
||||
my $names = '';
|
||||
my @temp = ();
|
||||
my $retInfo = xCAT::Utils->runcmd('lsresponse -d', -1, 1);
|
||||
|
||||
my @lines = split '\n', $ret;
|
||||
shift @lines;
|
||||
shift @lines;
|
||||
|
||||
foreach my $line (@lines) {
|
||||
$callback->( { data => $line } );
|
||||
shift @$retInfo;
|
||||
shift @$retInfo;
|
||||
foreach my $line (@$retInfo) {
|
||||
@temp = split(':', $line);
|
||||
$names = $names . @temp[0] . ';';
|
||||
}
|
||||
|
||||
$names = substr($names, 0, (length($names) - 1));
|
||||
$callback->( { data => $names } );
|
||||
}
|
||||
|
||||
sub web_lscondresp {
|
||||
|
Loading…
Reference in New Issue
Block a user