');
+ diaDiv.append('
');
+ diaDiv.append('
');
+ 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('
');
+ 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 = '
';
+
+ $('#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 {