From e2a92a3c97b032b8b1a59e3837ffe1546a78ee84 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Thu, 23 Dec 2010 03:03:19 +0000 Subject: [PATCH] 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 --- xCAT-UI/js/monitor/rmcmon.js | 157 +++++++++++++++++++++++++++- xCAT-server/lib/xcat/plugins/web.pm | 99 +++++++++++++++--- 2 files changed, 240 insertions(+), 16 deletions(-) diff --git a/xCAT-UI/js/monitor/rmcmon.js b/xCAT-UI/js/monitor/rmcmon.js index 33b593418..a0555bf7d 100644 --- a/xCAT-UI/js/monitor/rmcmon.js +++ b/xCAT-UI/js/monitor/rmcmon.js @@ -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 = $('
'); + diaDiv.append('
Predefined Condition
'); + diaDiv.append('
Group
'); + diaDiv.append('
'); + + diaDiv.dialog({ + modal: true, + width: 570, + close: function(event, ui){ + $(this).remove(); + }, + buttons: { + cancel : function(){ + $(this).dialog('close'); + }, + ok : function(){ + $('#changeStatus').empty().append('Status'); + 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 = '' + 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 = 'Predefined Condition'; + for (var i in conditions){ + name = conditions[i]; + name = name.substr(1, name.length - 2); + if (0 == i % 2){ + showStr += '' ; + } + else{ + showStr += ''; + } + } + showStr += '
' + name + '' + name + '
'; + + $('#changePreCond').append(showStr); + //adjust the dialog's position + $('#chScopeDiaDiv').dialog( "option", "position", 'center' ); + } + }); +} + +/** + * show the make response dialogue + * + * @param + + * @return + * + */ +function mkResponseDia(){ + var diaDiv = $('
'); + 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'); + } + } + }); } \ No newline at end of file diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index 124227efb..23471c540 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -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 {