');
+ diaDiv.append('Getting conditions').append(createLoader());
+
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'lscondition;-n',
+ msg : ''
+ },
+
+ success : function(data){
+ if (data.rsp[0]){
+ $('#startAss').empty().append(createConditionTable(data.rsp[0]));
+ $('#startAss').dialog("option", "position", 'center');
+ }
+ else{
+ $('#startAss').empty().append('There is not non-monitored condition.');
+ }
+ }
+ });
+
+ diaDiv.dialog({
+ modal: true,
+ width: 570,
+ close: function(event, ui){
+ $(this).remove();
+ },
+ buttons: {
+ cancel : function(){
+ $(this).dialog('close');
+ },
+ start : function(){
+ var conditionName = $('#startAss :checked').attr('value');
+ if (!conditionName){
+ alert('Select condition name please.');
+ return;
+ }
+ $('#rmcEventStatus').empty().append('Starting monitor on ' + conditionName).append(createLoader());
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'startcondresp;' + conditionName,
+ msg : ''
+ },
+
+ success : function(data){
+ $('#rmcEventStatus').empty().append(data.rsp[0]);
+ }
+ });
+ $(this).dialog('close');
+ }
+ }
+ });
+}
+
+/**
+ * stop the condition and response associations
+ *
+ * @param
+
+ * @return
+ *
+ */
+function stopCondRespDia(){
+ var diaDiv = $('
');
+ diaDiv.append('Getting conditions').append(createLoader());
+
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'lscondition;-m',
+ msg : ''
+ },
+
+ success : function(data){
+ if (data.rsp[0]){
+ $('#stopAss').empty().append(createConditionTable(data.rsp[0]));
+ $('#stopAss').dialog("option", "position", 'center');
+ }
+ else{
+ $('#stopAss').empty().append('There is not monitored condition.');
+ }
+ }
+ });
+
+ diaDiv.dialog({
+ modal: true,
+ width: 570,
+ close: function(event, ui){
+ $(this).remove();
+ },
+ buttons: {
+ cancel : function(){
+ $(this).dialog('close');
+ },
+ stop : function(){
+ var conditionName = $('#stopAss :checked').attr('value');
+ if (!conditionName){
+ alert('Select condition name please.');
+ return;
+ }
+ $('#rmcEventStatus').empty().append('Stoping monitor on ' + conditionName).append(createLoader());
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'stopcondresp;' + conditionName,
+ msg : ''
+ },
+
+ success : function(data){
+ $('#rmcEventStatus').empty().append(data.rsp[0]);
+ }
+ });
+ $(this).dialog('close');
+ }
+ }
+ });
+}
+
/**
* create the condition table for dialogue
*
diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm
index 1977aef1a..bae9eb91b 100644
--- a/xCAT-server/lib/xcat/plugins/web.pm
+++ b/xCAT-server/lib/xcat/plugins/web.pm
@@ -180,22 +180,18 @@ sub web_mkcondresp {
sub web_startcondresp {
my ( $request, $callback, $sub_req ) = @_;
- print Dumper( $request->{arg}->[0] ); #debug
- my $ret = system( $request->{arg}->[0] );
- if ($ret) {
-
- #to handle the failure
- }
+ my $conditionName = $request->{arg}->[1];
+ my $cmd = 'startcondresp "' . $conditionName . '"';
+ my $retInfo = xCAT::Utils->runcmd($cmd, -1, 1);
+ $callback->({ data => 'start monitor "' . $conditionName . '" Successful.' });
}
sub web_stopcondresp {
my ( $request, $callback, $sub_req ) = @_;
- print Dumper( $request->{arg}->[0] ); #debug
- my $ret = system( $request->{arg}->[0] );
- if ($ret) {
-
- #to handle the failure
- }
+ my $conditionName = $request->{arg}->[1];
+ my $cmd = 'stopcondresp "' . $conditionName . '"';
+ my $retInfo = xCAT::Utils->runcmd($cmd, -1, 1);
+ $callback->({ data => 'stop monitor "' . $conditionName . '" Successful.' });
}
sub web_lscond {
@@ -204,7 +200,7 @@ sub web_lscond {
my $names = '';
#list all the conditions on all lpars in this group
- if ($nodeRange){
+ if ($nodeRange && ('-' ne substr($nodeRange, 0, 1))){
my @nodes = xCAT::NodeRange::noderange($nodeRange);
my %tempHash;
my $nodeCount = @nodes;
@@ -236,8 +232,16 @@ sub web_lscond {
}
#only list the conditions on local.
else{
- my $retInfo = xCAT::Utils->runcmd('lscondition -d', -1, 1);
+ my $option = '';
+ if ($nodeRange){
+ $option = $nodeRange;
+ }
+ my $retInfo = xCAT::Utils->runcmd('lscondition -d ' . $option, -1, 1);
+ if (2 > @$retInfo){
+ return;
+ }
+
shift @$retInfo;
shift @$retInfo;
foreach my $line (@$retInfo) {