start and stop association
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8517 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -782,17 +782,23 @@ function loadRmcEventConfig(){
 | 
			
		||||
	});
 | 
			
		||||
	$('#rmcEventDiv').append(chCondScopeBut);
 | 
			
		||||
	
 | 
			
		||||
	var mkResponseBut = createButton('Make Response');
 | 
			
		||||
	mkResponseBut.bind('click', function(){
 | 
			
		||||
		mkResponseDia();
 | 
			
		||||
	});
 | 
			
		||||
	$('#rmcEventDiv').append(mkResponseBut);
 | 
			
		||||
	
 | 
			
		||||
	var mkConResBut = createButton('Configure Association');
 | 
			
		||||
	mkConResBut.bind('click', function(){
 | 
			
		||||
	var mkCondRespBut = createButton('Make/Remove Association');
 | 
			
		||||
	mkCondRespBut.bind('click', function(){
 | 
			
		||||
		mkCondRespDia();
 | 
			
		||||
	});
 | 
			
		||||
	$('#rmcEventDiv').append(mkConResBut);
 | 
			
		||||
	$('#rmcEventDiv').append(mkCondRespBut);
 | 
			
		||||
	
 | 
			
		||||
	var startCondRespBut = createButton('Start Association');
 | 
			
		||||
	startCondRespBut.bind('click', function(){
 | 
			
		||||
		startCondRespDia();
 | 
			
		||||
	});
 | 
			
		||||
	$('#rmcEventDiv').append(startCondRespBut);
 | 
			
		||||
	
 | 
			
		||||
	var stopCondRespBut = createButton('Stop Association');
 | 
			
		||||
	stopCondRespBut.bind('click', function(){
 | 
			
		||||
		stopCondRespDia();
 | 
			
		||||
	});
 | 
			
		||||
	$('#rmcEventDiv').append(stopCondRespBut);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -1073,6 +1079,148 @@ function mkResponseDia(){
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * start the condition and response associations
 | 
			
		||||
 * 
 | 
			
		||||
 * @param 
 | 
			
		||||
 | 
			
		||||
 * @return
 | 
			
		||||
 *        
 | 
			
		||||
 */
 | 
			
		||||
function startCondRespDia(){
 | 
			
		||||
	var diaDiv = $('<div title="Start Association" id="startAss"><div>');
 | 
			
		||||
	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 = $('<div title="Stop Association" id="stopAss"><div>');
 | 
			
		||||
	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
 | 
			
		||||
 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user